Ejemplo n.º 1
0
        private void Save_Data(bool msg)
        {
            try
            {
                _KTYTCPRepo = new KTYTCPRepo();
                int i = 0;
                foreach (int pos in _listUpdate)
                {
                    int id = Utils.CIntDef(gridView1.GetRowCellValue(pos, "ID"), 0);
                    KT_YTCP obj = _KTYTCPRepo.GetById(id);
                    if (obj != null)
                    {
                        obj.MA_YTCP = Utils.CStrDef(gridView1.GetRowCellValue(pos, "MA_YTCP"), "");
                        obj.TEN_YTCP_V = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TEN_YTCP_V"), "");
                        obj.TEN_YTCP_E = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TEN_YTCP_E"), "");
                        obj.MA_NHOM1 = Utils.CStrDef(gridView1.GetRowCellValue(pos, "MA_NHOM1"), "");
                        obj.TEN_NHOM1 = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TEN_NHOM1"), "");
                        obj.MA_NHOM2 = Utils.CStrDef(gridView1.GetRowCellValue(pos, "MA_NHOM2"), "");
                        obj.TEN_NHOM2 = Utils.CStrDef(gridView1.GetRowCellValue(pos, "TEN_NHOM2"), "");
                        obj.DUNO_VND = Utils.CIntDef(gridView1.GetRowCellValue(pos, "DUNO_VND"), 0);
                        obj.DUCO_VND = Utils.CIntDef(gridView1.GetRowCellValue(pos, "DUCO_VND"), 0);
                        obj.PSNO_VND = Utils.CIntDef(gridView1.GetRowCellValue(pos, "PSNO_VND"), 0);
                        obj.PSCO_VND = Utils.CIntDef(gridView1.GetRowCellValue(pos, "PSCO_VND"), 0);
                        obj.CKNO_VND = Utils.CIntDef(gridView1.GetRowCellValue(pos, "CKNO_VND"), 0);
                        obj.CKCO_VND = Utils.CIntDef(gridView1.GetRowCellValue(pos, "CKCO_VND"), 0);
                        obj.DUNO_USD = Utils.CIntDef(gridView1.GetRowCellValue(pos, "DUNO_USD"), 0);
                        obj.DUCO_USD = Utils.CIntDef(gridView1.GetRowCellValue(pos, "DUCO_USD"), 0);
                        obj.PSNO_USD = Utils.CIntDef(gridView1.GetRowCellValue(pos, "PSNO_USD"), 0);
                        obj.PSCO_USD = Utils.CIntDef(gridView1.GetRowCellValue(pos, "PSCO_USD"), 0);
                        obj.CKNO_USD = Utils.CIntDef(gridView1.GetRowCellValue(pos, "CKNO_USD"), 0);
                        obj.CKCO_USD = Utils.CIntDef(gridView1.GetRowCellValue(pos, "CKCO_USD"), 0);
                        obj.PSNO_LK_VND = Utils.CIntDef(gridView1.GetRowCellValue(pos, "PSNO_LK_VND"), 0);
                        obj.PSCO_LK_VND = Utils.CDblDef(gridView1.GetRowCellValue(pos, "PSCO_LK_VND"), 0);
                        obj.PSNO_LK_USD = Utils.CDblDef(gridView1.GetRowCellValue(pos, "PSNO_LK_USD"), 0);
                        obj.PSCO_LK_USD = Utils.CDblDef(gridView1.GetRowCellValue(pos, "PSCO_LK_USD"), 0);
                        obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(pos, "DANH_DAU"), "");                       

                        _KTYTCPRepo.Update(obj);
                        i++;
                    }
                }
                _listUpdate = new List<int>();
                //if (i > 0 && msg)
                //{
                //    MessageBox.Show("Lưu thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //}
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
 private void cboYTCPNo_SelectedIndexChanged(object sender, EventArgs e)
 {
     _KTYTCPRepo = new KTYTCPRepo();
     var item = _KTYTCPRepo.GetById(Utils.CIntDef(cboYTCPNo.SelectedValue, 0));
     if (item != null)
         txtYTCPNo.Text = item.TEN_YTCP_V;
 }
Ejemplo n.º 3
0
 private void cboYTCPCo_KeyDown(object sender, KeyEventArgs e)
 {
     _KTYTCPRepo = new KTYTCPRepo();
     var item = _KTYTCPRepo.GetById(Utils.CIntDef(cboYTCPCo.SelectedValue, 0));
     if (item != null)
         txtYTCPCo.Text = item.TEN_YTCP_V;
 }
Ejemplo n.º 4
0
 private void Save_Tick()
 {
     try
     {
         _KTYTCPRepo = new KTYTCPRepo();
         int id = Utils.CIntDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "ID").ToString(), 0);
         KT_YTCP obj = _KTYTCPRepo.GetById(id);
         if (obj != null)
         {
             obj.DANH_DAU = Utils.CStrDef(gridView1.GetRowCellValue(gridView1.FocusedRowHandle, "DANH_DAU"), "").Trim() == "T" ? "" : "T";
             _KTYTCPRepo.Update(obj);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 5
0
        private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e)
        {
            try
            {
                GridView view = sender as GridView;

                //validation
                GridColumn maCol = view.Columns["MA_YTCP"];
                string ma = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, maCol), "");
                if (ma.Trim().Length == 0 )
                {
                    e.Valid = false;
                    if (ma.Trim().Length == 0)
                        view.SetColumnError(maCol, "Mã yếu tố chi phí không được rổng");

                    return;
                }

                _KTYTCPRepo = new KTYTCPRepo();
                //Kiểm tra đây là dòng dữ liệu mới hay cũ, nếu là mới thì mình insert
                if (view.IsNewItemRow(e.RowHandle))
                {
                    //e.RowHandle trả về giá trị int là thứ tự của dòng hiện tại
                    KT_YTCP obj = new KT_YTCP();

                    obj.MA_YTCP = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_YTCP"), "");
                    obj.TEN_YTCP_V = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_YTCP_V"), "");
                    obj.TEN_YTCP_E = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_YTCP_E"), "");
                    obj.MA_NHOM1 = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_NHOM1"), "");
                    obj.TEN_NHOM1 = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_NHOM1"), "");
                    obj.MA_NHOM2 = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_NHOM2"), "");
                    obj.TEN_NHOM2 = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_NHOM2"), "");
                    obj.DUNO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "DUNO_VND"), 0);
                    obj.DUCO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "DUCO_VND"), 0);
                    obj.PSNO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "PSNO_VND"), 0);
                    obj.PSCO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "PSCO_VND"), 0);
                    obj.CKNO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "CKNO_VND"), 0);
                    obj.CKCO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "CKCO_VND"), 0);
                    obj.DUNO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "DUNO_USD"), 0);
                    obj.DUCO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "DUCO_USD"), 0);
                    obj.PSNO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "PSNO_USD"), 0);
                    obj.PSCO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "PSCO_USD"), 0);
                    obj.CKNO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "CKNO_USD"), 0);
                    obj.CKCO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "CKCO_USD"), 0);
                    obj.PSNO_LK_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "PSNO_LK_VND"), 0);
                    obj.PSCO_LK_VND = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "PSCO_LK_VND"), 0);
                    obj.PSNO_LK_USD = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "PSNO_LK_USD"), 0);
                    obj.PSCO_LK_USD = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "PSCO_LK_USD"), 0);
                    obj.DANH_DAU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DANH_DAU"), "");

                    _KTYTCPRepo.Create(obj);

                }
                //Cũ thì update
                else
                {
                    int id = Utils.CIntDef(view.GetRowCellValue(gridView1.FocusedRowHandle, "ID"), 0);
                    KT_YTCP obj = _KTYTCPRepo.GetById(id);
                    if (obj != null)
                    {
                        obj.MA_YTCP = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_YTCP"), "");
                        obj.TEN_YTCP_V = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_YTCP_V"), "");
                        obj.TEN_YTCP_E = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_YTCP_E"), "");
                        obj.MA_NHOM1 = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_NHOM1"), "");
                        obj.TEN_NHOM1 = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_NHOM1"), "");
                        obj.MA_NHOM2 = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "MA_NHOM2"), "");
                        obj.TEN_NHOM2 = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "TEN_NHOM2"), "");
                        obj.DUNO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "DUNO_VND"), 0);
                        obj.DUCO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "DUCO_VND"), 0);
                        obj.PSNO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "PSNO_VND"), 0);
                        obj.PSCO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "PSCO_VND"), 0);
                        obj.CKNO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "CKNO_VND"), 0);
                        obj.CKCO_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "CKCO_VND"), 0);
                        obj.DUNO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "DUNO_USD"), 0);
                        obj.DUCO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "DUCO_USD"), 0);
                        obj.PSNO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "PSNO_USD"), 0);
                        obj.PSCO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "PSCO_USD"), 0);
                        obj.CKNO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "CKNO_USD"), 0);
                        obj.CKCO_USD = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "CKCO_USD"), 0);
                        obj.PSNO_LK_VND = Utils.CIntDef(view.GetRowCellValue(e.RowHandle, "PSNO_LK_VND"), 0);
                        obj.PSCO_LK_VND = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "PSCO_LK_VND"), 0);
                        obj.PSNO_LK_USD = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "PSNO_LK_USD"), 0);
                        obj.PSCO_LK_USD = Utils.CDblDef(view.GetRowCellValue(e.RowHandle, "PSCO_LK_USD"), 0);
                        obj.DANH_DAU = Utils.CStrDef(view.GetRowCellValue(e.RowHandle, "DANH_DAU"), "");

                        _KTYTCPRepo.Update(obj);
                    }

                }
                Load_Data();
            }
            catch (Exception ex)
            {
                e.Valid = false;
                MessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }