public bool Color_Insert(Color_Info p_Supplier_Info, ref decimal _id) { try { SqlParameter[] spParameter = new SqlParameter[3]; spParameter[0] = new SqlParameter("@ColorCode", SqlDbType.NVarChar); spParameter[0].Direction = ParameterDirection.Input; spParameter[0].Value = p_Supplier_Info.ColorCode; spParameter[1] = new SqlParameter("@ColorName", SqlDbType.NVarChar); spParameter[1].Direction = ParameterDirection.Input; spParameter[1].Value = p_Supplier_Info.ColorName; spParameter[2] = new SqlParameter("@Color_Id", SqlDbType.Int); spParameter[2].Direction = ParameterDirection.Output; spParameter[2].Value = _id; SqlHelper.ExecuteNonQuery(CommonData.ConnectionString, CommandType.StoredProcedure, "proc_Color_Insert", spParameter); _id = Convert.ToDecimal(spParameter[2].Value); return(true); } catch (Exception ex) { CommonData.log.Error(ex.ToString()); return(false); } }
void Color_Delete() { try { c_row_select = dgrColor.SelectedIndex; Color_Info _Color_Info = (Color_Info)dgrColor.SelectedItem; if (_Color_Info == null) { return; } MessageBoxResult result = NoteBox.Show("Bạn chắc chắn muốn xóa màu này hay không?", "Thông báo", NoteBoxLevel.Question); if (MessageBoxResult.Yes == result) { if (c_Color_Controller.Color_Delete(_Color_Info.Color_Id)) { NoteBox.Show("Xóa dữ liệu thành công"); LoadData(); } } else { DataGridHelper.NVSFocus(dgrColor, c_row_select, 0); } } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }
void Color_Insert() { try { frmCreate_Color _frmCreate_Color = new frmCreate_Color(); _frmCreate_Color.c_type = Convert.ToInt16(Form_Type.Insert); _frmCreate_Color.Owner = Window.GetWindow(this); _frmCreate_Color.ShowDialog(); if (_frmCreate_Color.c_id_insert != 0) { LoadData(); for (int i = 0; i < c_lst.Count; i++) { Color_Info ui = (Color_Info)c_lst[i]; if (ui.Color_Id == _frmCreate_Color.c_id_insert) { c_row_select = i; _frmCreate_Color.c_id_insert = 0; break; } } } DataGridHelper.NVSFocus(dgrColor, c_row_select, 0); } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }
void Accept() { try { if (!CheckValidate_F()) { return; } MessageBoxResult result = NoteBox.Show("Bạn chắc chắn muốn thêm mới màu hay không?", "Thông báo", NoteBoxLevel.Question); if (MessageBoxResult.Yes == result) { Color_Info _Color_Info = new Color_Info(); _Color_Info.ColorName = txtName.Text; _Color_Info.ColorCode = txtCode.Text; decimal _id = 0; Color_Controller _Color_Controller = new Color_Controller(); if (_Color_Controller.Color_Insert(_Color_Info, ref _id)) { NoteBox.Show("Thêm mới thành công"); c_id_insert = _id; this.Close(); } else { NoteBox.Show("Có lỗi trong quá trình thêm mới", "", NoteBoxLevel.Error); } } } catch (Exception ex) { CommonData.log.Error(ex.ToString()); } }