public bool InsertDepart(CodeTableVO category)
        {
            string sql = "CMG_InsertDepart";

            try
            {
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    cmd.Parameters.AddWithValue("@CodeTable_CodeName", category.CodeTable_CodeName);
                    cmd.Parameters.AddWithValue("@CodeTable_CodeExplain", category.CodeTable_CodeExplain);

                    conn.Open();
                    var rowsAffected = cmd.ExecuteNonQuery();
                    return(rowsAffected > 0);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }
        public void UpdateCategory()
        {
            CodeTableVO category = new CodeTableVO();

            category.CodeTable_CodeName = txtName.Text;

            if (txtContext.Text.Length > 0)
            {
                category.CodeTable_CodeExplain = txtContext.Text;
            }
            else
            {
                category.CodeTable_CodeExplain = cboContext.SelectedValue.ToString();
            }

            category.CodeTable_CodeID = code;

            try
            {
                CodeTableService service = new CodeTableService();
                service.UpdateCodeTable(category);
            }
            catch (Exception err)
            {
                Log.WriteError(err.Message, err);
            }
        }
        public bool UpdateCodeTable(CodeTableVO code)
        {
            string sql = "Update CodeTable set CodeTable_CodeName = @CodeTable_CodeName, CodeTable_CodeExplain = @CodeTable_CodeExplain where CodeTable_CodeID = @CodeTable_CodeID ";

            try
            {
                using (SqlCommand cmd = new SqlCommand(sql, conn))
                {
                    cmd.Parameters.AddWithValue("@CodeTable_CodeName", code.CodeTable_CodeName);
                    cmd.Parameters.AddWithValue("@CodeTable_CodeExplain", code.CodeTable_CodeExplain);
                    cmd.Parameters.AddWithValue("@CodeTable_CodeID", code.CodeTable_CodeID);

                    conn.Open();
                    var rowsAffected = cmd.ExecuteNonQuery();
                    return(rowsAffected > 0);
                }
            }
            catch
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }
Esempio n. 4
0
 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex < dgvDepartment.Rows.Count && e.RowIndex > -1)
     {
         item = new CodeTableVO
         {
             CodeTable_CodeID      = dgvDepartment.Rows[e.RowIndex].Cells[0].Value.ToString(),
             CodeTable_CodeName    = dgvDepartment.Rows[e.RowIndex].Cells[1].Value.ToString(),
             CodeTable_CodeExplain = dgvDepartment.Rows[e.RowIndex].Cells[2].Value.ToString()
         };
     }
 }
        // 부서 등록
        private void InsertDepart()
        {
            CodeTableVO dept = new CodeTableVO();

            dept.CodeTable_CodeName    = txtName.Text;
            dept.CodeTable_CodeExplain = txtContext.Text;

            try
            {
                CodeTableService service = new CodeTableService();
                service.InsertDepart(dept);
            }
            catch (Exception err)
            {
                Log.WriteError(err.Message, err);
            }
        }
        public void UpdateDepart()
        {
            CodeTableVO depart = new CodeTableVO();

            depart.CodeTable_CodeName    = txtName.Text;
            depart.CodeTable_CodeExplain = txtContext.Text;
            depart.CodeTable_CodeID      = code;

            try
            {
                CodeTableService service = new CodeTableService();
                service.UpdateCodeTable(depart);
            }
            catch (Exception err)
            {
                Log.WriteError(err.Message, err);
            }
        }
        public CategoryInsUp(EditMode editMode, CodeTableVO item)
        {
            InitializeComponent();

            if (editMode == EditMode.Update)
            {
                mode           = "Update";
                lblName.Text   = "카테고리 수정";
                code           = item.CodeTable_CodeID;
                txtName.Text   = item.CodeTable_CodeName;
                info           = item.CodeTable_CodeExplain;
                pbxTitle.Image = Resources.Edit_32x32;
            }
            else
            {
                mode           = "Insert";
                lblName.Text   = "카테고리 등록";
                pbxTitle.Image = Resources.AddFile_32x32;
            }
        }
        public DepartmentInsUp(EditMode editMode, CodeTableVO item)
        {
            InitializeComponent();

            if (editMode == EditMode.Update)
            {
                lblName.Text    = "부서 수정";
                mode            = "Update";
                pbxTitle.Image  = Resources.Edit_32x32;
                code            = item.CodeTable_CodeID;
                txtName.Text    = item.CodeTable_CodeName;
                txtContext.Text = item.CodeTable_CodeExplain;
            }
            else
            {
                lblName.Text   = "부서 등록";
                mode           = "Insert";
                pbxTitle.Image = Resources.AddFile_32x32;
            }
        }
        public bool UpdateCodeTable(CodeTableVO code)
        {
            CodeTableDAC dac = new CodeTableDAC();

            return(dac.UpdateCodeTable(code));
        }
        public bool InsertDepart(CodeTableVO dept)
        {
            CodeTableDAC dac = new CodeTableDAC();

            return(dac.InsertDepart(dept));
        }
        public bool InsertCategory(CodeTableVO category)
        {
            CodeTableDAC dac = new CodeTableDAC();

            return(dac.InsertCategory(category));
        }