add_property.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:3k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- public partial class web_approvel_flow_add_property : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- LoginDAO.CheckLogin(Session, Response, "../../", 2);
- }
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- SqlTransaction tx = conn.BeginTransaction();
- int id = 1;
- try
- {
- SqlCommand cmd = new SqlCommand("select max(id) from OA_FLOW_MAIN", conn);
- cmd.Transaction = tx;
- try
- {
- id = Convert.ToInt32(cmd.ExecuteScalar().ToString()) + 1;
- }
- catch { }
- if (!DepartmentIds.Value.Equals(""))
- {
- string cre_user = "";
- DateMgr mgr = new DateMgr();
- if (Session["user"] != null)
- {
- User user = (User)Session["user"];
- cre_user = user.Emp_name;
- }
- cmd = new SqlCommand("insert into OA_FLOW_MAIN(id, name, description, "+
- "type, cre_user, cre_date) values ("+id+",'"+TxtName.Text+"','"+TxtDescription.Text+
- "','" + RbType.SelectedValue + "','" + cre_user + "','" + mgr.getDateTime() + "')", conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- string[] ids = DepartmentIds.Value.Split(new char[] { ',' });
- int department_id = 1;
- cmd = new SqlCommand("select max(id) from OA_FLOW_DEPARTMENT", conn);
- cmd.Transaction = tx;
- try
- {
- department_id = Convert.ToInt32(cmd.ExecuteScalar().ToString())+1;
- }
- catch{ }
- for (int i = 0; i < ids.Length; i++)
- {
- cmd = new SqlCommand("insert into OA_FLOW_DEPARTMENT(id, main_id, department_id)"+
- "values("+department_id+",'"+id+"','"+ids[i]+"')", conn);
- cmd.Transaction = tx;
- cmd.ExecuteNonQuery();
- department_id++;
- }
- }
- tx.Commit();
- }
- catch (Exception ex)
- {
- Response.Write(ex.Message);
- tx.Rollback();
- }
- conn.Close();
- Session["main"] = id.ToString();
- Response.Write("<script language='javascript'>window.parent.location='flow_index.aspx'</script>");
- }
- }