Beispiel #1
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Del_Click(object sender, EventArgs e)
        {
            try
            {
                DataRow dr = gv_ANXX.GetDataRow(gv_ANXX.FocusedRowHandle);
                if (dr != null)
                {
                    ModTS_DEPT model = bllDept.GetModel(dr["C_ID"].ToString());
                    if (model != null)
                    {
                        model.N_STATUS   = 0;
                        model.C_EMP_ID   = UserInfo.userID;
                        model.C_EMP_NAME = UserInfo.userName;
                        model.D_MOD_DT   = ServerTime.timeNow();
                        if (bllDept.Update(model))
                        {
                            MessageBox.Show("删除成功!");

                            DataTable dt_ITEM = bllDept.Get_List(tag).Tables[0];
                            gc_ANXX.DataSource = dt_ITEM;
                            gv_ANXX.BestFitColumns();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ModTS_DEPT model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TS_DEPT set ");
            strSql.Append("C_PARENT_ID=:C_PARENT_ID,");
            strSql.Append("C_CODE=:C_CODE,");
            strSql.Append("C_NAME=:C_NAME,");
            strSql.Append("C_DESC=:C_DESC,");
            strSql.Append("N_STATUS=:N_STATUS,");
            strSql.Append("C_DEPTH=:C_DEPTH,");
            strSql.Append("N_DEPTATTR=:N_DEPTATTR,");
            strSql.Append("C_EMP_ID=:C_EMP_ID,");
            strSql.Append("C_EMP_NAME=:C_EMP_NAME,");
            strSql.Append("D_MOD_DT=:D_MOD_DT");
            strSql.Append(" where C_ID=:C_ID ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_PARENT_ID", OracleDbType.Varchar2,  50),
                new OracleParameter(":C_CODE",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_NAME",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_DESC",      OracleDbType.Varchar2, 200),
                new OracleParameter(":N_STATUS",    OracleDbType.Int32,      1),
                new OracleParameter(":C_DEPTH",     OracleDbType.Int32,      3),
                new OracleParameter(":N_DEPTATTR",  OracleDbType.Varchar2,   9),
                new OracleParameter(":C_EMP_ID",    OracleDbType.Varchar2,  50),
                new OracleParameter(":C_EMP_NAME",  OracleDbType.Varchar2,  20),
                new OracleParameter(":D_MOD_DT",    OracleDbType.Date),
                new OracleParameter(":C_ID",        OracleDbType.Varchar2, 50)
            };
            parameters[0].Value  = model.C_PARENT_ID;
            parameters[1].Value  = model.C_CODE;
            parameters[2].Value  = model.C_NAME;
            parameters[3].Value  = model.C_DESC;
            parameters[4].Value  = model.N_STATUS;
            parameters[5].Value  = model.C_DEPTH;
            parameters[6].Value  = model.N_DEPTATTR;
            parameters[7].Value  = model.C_EMP_ID;
            parameters[8].Value  = model.C_EMP_NAME;
            parameters[9].Value  = model.D_MOD_DT;
            parameters[10].Value = model.C_ID;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ModTS_DEPT DataRowToModel(DataRow row)
        {
            ModTS_DEPT model = new ModTS_DEPT();

            if (row != null)
            {
                if (row["C_ID"] != null)
                {
                    model.C_ID = row["C_ID"].ToString();
                }
                if (row["C_PARENT_ID"] != null)
                {
                    model.C_PARENT_ID = row["C_PARENT_ID"].ToString();
                }
                if (row["C_CODE"] != null)
                {
                    model.C_CODE = row["C_CODE"].ToString();
                }
                if (row["C_NAME"] != null)
                {
                    model.C_NAME = row["C_NAME"].ToString();
                }
                if (row["C_DESC"] != null)
                {
                    model.C_DESC = row["C_DESC"].ToString();
                }
                if (row["N_STATUS"] != null && row["N_STATUS"].ToString() != "")
                {
                    model.N_STATUS = decimal.Parse(row["N_STATUS"].ToString());
                }
                if (row["C_DEPTH"] != null && row["C_DEPTH"].ToString() != "")
                {
                    model.C_DEPTH = decimal.Parse(row["C_DEPTH"].ToString());
                }
                if (row["N_DEPTATTR"] != null)
                {
                    model.N_DEPTATTR = row["N_DEPTATTR"].ToString();
                }
                if (row["C_EMP_ID"] != null)
                {
                    model.C_EMP_ID = row["C_EMP_ID"].ToString();
                }
                if (row["C_EMP_NAME"] != null)
                {
                    model.C_EMP_NAME = row["C_EMP_NAME"].ToString();
                }
                if (row["D_MOD_DT"] != null && row["D_MOD_DT"].ToString() != "")
                {
                    model.D_MOD_DT = DateTime.Parse(row["D_MOD_DT"].ToString());
                }
            }
            return(model);
        }
Beispiel #4
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Add_Click(object sender, EventArgs e)
        {
            try
            {
                ModTS_DEPT model = new ModTS_DEPT();

                if (string.IsNullOrEmpty(txt_Name.Text.Trim()))
                {
                    MessageBox.Show("请填写部门名称!");
                    return;
                }

                model.C_NAME      = txt_Name.Text.Trim();
                model.C_PARENT_ID = tag;

                if (max == "0")
                {
                    max = stdCode + "01";
                }
                else
                {
                    max = (Convert.ToInt32(max) + 1).ToString();
                }

                model.C_CODE   = max;
                model.N_STATUS = 1;

                if (name == "-1")
                {
                    model.C_DEPTH = 1;
                }

                model.C_EMP_ID   = UserInfo.userID;
                model.C_EMP_NAME = UserInfo.menuName;

                if (bllDept.Add(model))
                {
                    MessageBox.Show("添加成功!");

                    DataTable dt_ITEM = bllDept.Get_List(tag).Tables[0];
                    gc_ANXX.DataSource = dt_ITEM;
                    gv_ANXX.BestFitColumns();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ModTS_DEPT model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TS_DEPT(");
            strSql.Append("C_PARENT_ID,C_CODE,C_NAME,C_DESC,N_STATUS,C_DEPTH,N_DEPTATTR,C_EMP_ID,C_EMP_NAME)");
            strSql.Append(" values (");
            strSql.Append(":C_PARENT_ID,:C_CODE,:C_NAME,:C_DESC,:N_STATUS,:C_DEPTH,:N_DEPTATTR,:C_EMP_ID,:C_EMP_NAME)");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_PARENT_ID", OracleDbType.Varchar2,  50),
                new OracleParameter(":C_CODE",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_NAME",      OracleDbType.Varchar2, 100),
                new OracleParameter(":C_DESC",      OracleDbType.Varchar2, 200),
                new OracleParameter(":N_STATUS",    OracleDbType.Int32,      1),
                new OracleParameter(":C_DEPTH",     OracleDbType.Int32,      3),
                new OracleParameter(":N_DEPTATTR",  OracleDbType.Varchar2,   9),
                new OracleParameter(":C_EMP_ID",    OracleDbType.Varchar2,  50),
                new OracleParameter(":C_EMP_NAME",  OracleDbType.Varchar2, 20)
            };
            parameters[0].Value = model.C_PARENT_ID;
            parameters[1].Value = model.C_CODE;
            parameters[2].Value = model.C_NAME;
            parameters[3].Value = model.C_DESC;
            parameters[4].Value = model.N_STATUS;
            parameters[5].Value = model.C_DEPTH;
            parameters[6].Value = model.N_DEPTATTR;
            parameters[7].Value = model.C_EMP_ID;
            parameters[8].Value = model.C_EMP_NAME;

            int rows = DbHelperOra.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #6
0
        private void btn_Edit_Click(object sender, EventArgs e)
        {
            try
            {
                DataRow dr = gv_ANXX.GetDataRow(gv_ANXX.FocusedRowHandle);
                if (dr != null)
                {
                    ModTS_DEPT model = bllDept.GetModel(dr["C_ID"].ToString());
                    if (model != null)
                    {
                        if (string.IsNullOrEmpty(gv_ANXX.GetRowCellValue(gv_ANXX.FocusedRowHandle, "C_NAME").ToString()))
                        {
                            MessageBox.Show("部门名称不能为空!");
                            return;
                        }

                        model.C_NAME     = gv_ANXX.GetRowCellValue(gv_ANXX.FocusedRowHandle, "C_NAME").ToString();
                        model.C_EMP_ID   = UserInfo.userID;
                        model.C_EMP_NAME = UserInfo.userName;
                        model.D_MOD_DT   = ServerTime.timeNow();

                        if (bllDept.Update(model))
                        {
                            MessageBox.Show("修改成功!");

                            DataTable dt_ITEM = bllDept.Get_List(tag).Tables[0];
                            gc_ANXX.DataSource = dt_ITEM;
                            gv_ANXX.BestFitColumns();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ModTS_DEPT GetModel(string C_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select C_ID,C_PARENT_ID,C_CODE,C_NAME,C_DESC,N_STATUS,C_DEPTH,N_DEPTATTR,C_EMP_ID,C_EMP_NAME,D_MOD_DT from TS_DEPT ");
            strSql.Append(" where C_ID=:C_ID ");
            OracleParameter[] parameters =
            {
                new OracleParameter(":C_ID", OracleDbType.Varchar2, 50)
            };
            parameters[0].Value = C_ID;

            ModTS_DEPT model = new ModTS_DEPT();
            DataSet    ds    = DbHelperOra.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #8
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(ModTS_DEPT model)
 {
     return(dal.Update(model));
 }
Beispiel #9
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(ModTS_DEPT model)
 {
     return(dal.Add(model));
 }