private void grvUser_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView View = (DevExpress.XtraGrid.Views.Grid.GridView)sender; DevExpress.XtraGrid.Columns.GridColumn sMaNhom = View.Columns["ID_NHOM"]; DevExpress.XtraGrid.Columns.GridColumn sTenUser = View.Columns["USER_NAME"]; DevExpress.XtraGrid.Columns.GridColumn sFullName = View.Columns["FULL_NAME"]; if (View.GetRowCellValue(e.RowHandle, sTenUser).ToString() == "") { e.Valid = false; View.SetColumnError(sTenUser, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage)); XtraMessageBox.Show(Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (View.GetRowCellValue(e.RowHandle, sTenUser).ToString() == "") { e.Valid = false; View.SetColumnError(sTenUser, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage)); XtraMessageBox.Show(Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (!CheckUser(View.GetRowCellValue(e.RowHandle, sTenUser).ToString())) { e.Valid = false; View.SetColumnError(sTenUser, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgDatontainguoidung", Commons.Modules.TypeLanguage)); XtraMessageBox.Show(Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgDatontainguoidung", Commons.Modules.TypeLanguage), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (View.GetRowCellValue(e.RowHandle, sFullName).ToString() == "") { e.Valid = false; View.SetColumnError(sFullName, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraFullNameNULL", Commons.Modules.TypeLanguage)); XtraMessageBox.Show(Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraFullNameNULL", Commons.Modules.TypeLanguage), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public void tsbtplbl(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string roleid, string subsys, string ngaychungtu, string userid, DataTable khach) { try { Frm_plbl u = new Frm_plbl(); u.myac = new Frm_plbl.ac(F.refreshhdkh); u.getactive(a); u.getroleid(roleid); u.getsub(subsys); u.getkhach(khach); u.getdate(ngaychungtu); u.getuser(userid); try { if (a == "1") { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } else { try { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "Đơn vị").ToString()); } catch { u.getrole(gen.GetString("select Top 1 StockCode from Stock where StockID in (select StockID from MSC_UserJoinStock where UserID='" + userid + "') order by StockCode")); } } } catch { } u.ShowDialog(); } catch { MessageBox.Show("Vui lòng chọn Phụ lục - Bảo lãnh trước khi sửa."); } }
public void tsbtdeletepkt(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F) { try { string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(); if (gen.GetString("select Posted from GLVoucher where RefID='" + name + "'") == "True") { XtraMessageBox.Show("Phiếu đã được ghi sổ không thể xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (XtraMessageBox.Show("Bạn có chắc muốn xóa phiếu kế toán " + view.GetRowCellValue(view.FocusedRowHandle, "Số chứng từ").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { gen.ExcuteNonquery("delete from GLVoucher where RefID='" + name + "'"); gen.ExcuteNonquery("delete from GLVoucherDetail where RefID='" + name + "'"); gen.ExcuteNonquery("insert into HACHTOANBK select *,GetDate() from HACHTOAN where RefID='" + name + "'"); gen.ExcuteNonquery("delete HACHTOAN where RefID='" + name + "'"); view.DeleteRow(view.FocusedRowHandle); /*gen.ExcuteNonquery("update GLVoucher set Cancel='True',Posted='True' where RefID='" + name + "'"); * view.SetRowCellValue(view.FocusedRowHandle, view.Columns["Hủy"], "True"); * view.SetRowCellValue(view.FocusedRowHandle, view.Columns["Số tiền"], "0");*/ } } catch { XtraMessageBox.Show("Vui lòng chọn phiếu thu ngân hàng trước khi xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void SpeedSearch() { int iRowPos = gvwCourse.FocusedRowHandle; string strGridValue = ""; foreach (DevExpress.XtraGrid.Columns.GridColumn col in gvwCourse.Columns) { if (col.SortIndex >= 0) { for (int intCtr = 0; intCtr < gvwCourse.RowCount; intCtr++) { if (col.VisibleIndex > -1) { if (gvwCourse.GetRowCellValue(intCtr, col) != System.DBNull.Value) { strGridValue = gvwCourse.GetRowCellValue(intCtr, col).ToString(); if (strGridValue.ToUpper().Trim().StartsWith(txt_SpeedSearch.Text.Trim().ToUpper())) { gvwCourse.FocusedRowHandle = intCtr; break; } } } } } } }
public void tsbtcsncc(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string userid, string ngaychungtu) { try { Frm_chinhsach u = new Frm_chinhsach(); u.myac = new Frm_chinhsach.ac(F.refreshcsncc); u.getactive(a); u.getdate(ngaychungtu); userid = gen.GetString("select Top 1 FullName from MSC_User where UserID='" + userid + "'"); u.getuser(userid); try { if (a == "1") { if (userid.ToUpper() == view.GetRowCellValue(view.FocusedRowHandle, "Người lập").ToString().ToUpper() || Double.Parse(gen.GetString("select Top 1 AuthenticationType from MSC_User where UserID='" + userid + "'")) > 1) { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } else { XtraMessageBox.Show("Bạn không phải người lập chính sách này."); return; } } } catch { } u.ShowDialog(); } catch { XtraMessageBox.Show("Vui lòng chọn chính sách trước khi sửa."); } }
public void tsbtdeletepnk(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F) { try { string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(); if (gen.GetString("select Posted from INInward where RefID='" + name + "'") == "True") { XtraMessageBox.Show("Phiếu đã được ghi sổ không thể xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (XtraMessageBox.Show("Bạn có chắc muốn xóa phiếu nhập kho gas " + view.GetRowCellValue(view.FocusedRowHandle, "Số chứng từ").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { string id = gen.GetString("select refSUID from INInward where refID='" + name + "'"); gen.ExcuteNonquery("delete from INInwardSUDetail where RefID='" + id + "'"); gen.ExcuteNonquery("delete from INInwardSU where RefID='" + id + "'"); gen.ExcuteNonquery("delete HACHTOAN where RefID='" + id + "'"); gen.ExcuteNonquery("delete from INInwardDetail where RefID='" + name + "'"); gen.ExcuteNonquery("delete from INInward where RefID='" + name + "'"); gen.ExcuteNonquery("delete HACHTOAN where RefID='" + name + "'"); view.DeleteRow(view.FocusedRowHandle); } } catch { XtraMessageBox.Show("Vui lòng chọn phiếu nhập kho gas trước khi xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void tsbtdeletepnk(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F) { try { string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(); if (view.GetRowCellValue(view.FocusedRowHandle, "Duyệt").ToString() == "True") { XtraMessageBox.Show("Phiếu đã được duyệt không thể xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (view.GetRowCellValue(view.FocusedRowHandle, "Hóa đơn").ToString() == "True") { XtraMessageBox.Show("Phiếu đã được chuyển hóa đơn không thể xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (gen.GetString("select Posted from DDHNCC where RefID='" + name + "'") == "True") { XtraMessageBox.Show("Phiếu đã được ghi sổ không thể xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (XtraMessageBox.Show("Bạn có chắc muốn xóa đơn đặt hàng " + view.GetRowCellValue(view.FocusedRowHandle, "Số chứng từ").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { gen.ExcuteNonquery("delete from DDHNCC where RefID='" + name + "'"); gen.ExcuteNonquery("delete from DDHNCCDetail where RefID='" + name + "'"); view.DeleteRow(view.FocusedRowHandle); } } catch { XtraMessageBox.Show("Vui lòng chọn đơn đặt hàng trước khi xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void tsbtdeletepnk(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F) { try { string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(); try { Double temp = Double.Parse(gen.GetString("select sum(QuantityConvertExits) as QuantityConvertExits from INInwardDetailTT where RefID= '" + name + "'")); if (temp != 0) { XtraMessageBox.Show("Một phần phiếu đã được xuất hóa đơn bạn không thể xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { if (XtraMessageBox.Show("Bạn có chắc muốn xóa phiếu xuất kho " + view.GetRowCellValue(view.FocusedRowHandle, "Số chứng từ").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { gen.ExcuteNonquery("delete from INInwardTT where RefID='" + name + "'"); gen.ExcuteNonquery("delete from INInwardDetailTT where RefID='" + name + "'"); view.DeleteRow(view.FocusedRowHandle); } } } catch { if (XtraMessageBox.Show("Bạn có chắc muốn xóa phiếu xuất kho " + view.GetRowCellValue(view.FocusedRowHandle, "Số chứng từ").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { gen.ExcuteNonquery("delete from INInwardTT where RefID='" + name + "'"); } } } catch { XtraMessageBox.Show("Vui lòng chọn phiếu trước khi xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void tsbtpck(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string roleid, string subsys, string ngaychungtu, string userid, string branchid, DataTable khach, DataTable hang) { try { Frm_hoadonxhgb u = new Frm_hoadonxhgb(); u.myac = new Frm_hoadonxhgb.ac(F.refreshhdxhgb); u.getpt("tsbthdxhgb"); u.getactive(a); u.getsub(subsys); u.getroleid(roleid); u.gethang(hang); u.getkhach(khach); u.getdate(ngaychungtu); u.getuser(userid); u.getbranch(branchid); if (a == "1") { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } else { try { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "Mã kho").ToString()); } catch { } } u.ShowDialog(); } catch { MessageBox.Show("Vui lòng chọn phiếu xuất hàng gửi bán trước khi sửa."); } }
public void tsbtdeletetgp(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F) { try { string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(); if (XtraMessageBox.Show("Bạn có chắc muốn xóa " + view.GetRowCellValue(view.FocusedRowHandle, "Diễn giải").ToString() + " từ kho " + view.GetRowCellValue(view.FocusedRowHandle, "Mã kho").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { gen.ExcuteNonquery("delete from Descasc where DescascID='" + name + "'"); view.DeleteRow(view.FocusedRowHandle); } } catch { XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void deleteaccount(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F) { try { string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(); if (MessageBox.Show("Bạn có chắc muốn xóa " + view.GetRowCellValue(view.FocusedRowHandle, "Số tài khoản").ToString().Trim() + "?", "Cảnh báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { gen.ExcuteNonquery("delete from Account where AccountID='" + name + "'"); view.DeleteRow(view.FocusedRowHandle); } } catch { MessageBox.Show("Vui lòng chọn tài khoản trước khi xóa."); } }
public void tsbtdeleteplbl(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F) { try { string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(); if (XtraMessageBox.Show("Bạn có chắc muốn xóa Phụ lục - Bảo lãnh " + view.GetRowCellValue(view.FocusedRowHandle, "Số").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { gen.ExcuteNonquery("delete from ContractB where ContractID='" + name + "'"); view.DeleteRow(view.FocusedRowHandle); } } catch { XtraMessageBox.Show("Vui lòng chọn Phụ lục - Bảo lãnh trước khi xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void grvDCTroCapBHXH_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView View = (DevExpress.XtraGrid.Views.Grid.GridView)sender; DevExpress.XtraGrid.Columns.GridColumn ID_CN = View.Columns["ID_CN"]; DevExpress.XtraGrid.Columns.GridColumn NGHI_TU_NGAY = View.Columns["NGHI_TU_NGAY"]; DevExpress.XtraGrid.Columns.GridColumn NGHI_DEN_NGAY = View.Columns["NGHI_DEN_NGAY"]; DevExpress.XtraGrid.Columns.GridColumn ID_LDV = View.Columns["ID_LDV"]; DevExpress.XtraGrid.Columns.GridColumn ID_HTNTC = View.Columns["ID_LDV"]; if (View.GetRowCellValue(e.RowHandle, ID_LDV).ToString() == "") { e.Valid = false; View.SetColumnError(ID_LDV, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraLDVNULL", Commons.Modules.TypeLanguage)); return; } if (View.GetRowCellValue(e.RowHandle, ID_HTNTC).ToString() == "") { e.Valid = false; View.SetColumnError(ID_HTNTC, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraHTNTCNULL", Commons.Modules.TypeLanguage)); return; } if (View.GetRowCellValue(e.RowHandle, NGHI_TU_NGAY).ToString() == "") { e.Valid = false; View.SetColumnError(NGHI_TU_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTuNgayCNULL", Commons.Modules.TypeLanguage)); return; } if (View.GetRowCellValue(e.RowHandle, NGHI_DEN_NGAY).ToString() == "") { e.Valid = false; View.SetColumnError(NGHI_DEN_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraDenNgayNULL", Commons.Modules.TypeLanguage)); return; } //kiểm tra dữ liệu trùng DataTable tempt = Commons.Modules.ObjSystems.ConvertDatatable(grvDCTroCapBHXH); int n = 0; //kiểm tra trùng trên view try { n = tempt.AsEnumerable().Count(x => x.Field <Int64>("ID_CN") == Convert.ToInt64(View.GetRowCellValue(e.RowHandle, ID_CN)) && x.Field <DateTime>("NGHI_TU_NGAY") == Convert.ToDateTime(View.GetRowCellValue(e.RowHandle, NGHI_TU_NGAY))); } catch (Exception ex) { } if (n > 1) { e.Valid = false; View.SetColumnError(ID_CN, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgTrungDuLieu", Commons.Modules.TypeLanguage)); View.SetColumnError(NGHI_TU_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgTrungDuLieu", Commons.Modules.TypeLanguage)); val = false; return; } }
public void tsbtdeletepttm(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F) { try { string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(); if (XtraMessageBox.Show("Bạn có chắc muốn xóa phiếu thu " + view.GetRowCellValue(view.FocusedRowHandle, "Số chứng từ").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { gen.ExcuteNonquery("delete from CAReceiptTT where RefID='" + name + "'"); gen.ExcuteNonquery("delete from CAReceiptDetailTT where RefID='" + name + "'"); view.DeleteRow(view.FocusedRowHandle); } } catch { XtraMessageBox.Show("Vui lòng chọn phiếu thu tiền mặt trước khi xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void AddRow(DevExpress.XtraGrid.Views.Grid.GridView View) { int currentRow; currentRow = View.FocusedRowHandle; if (currentRow < 0) { currentRow = View.GetDataRowHandleByGroupRowHandle(currentRow); } if (View.GroupedColumns.Count == 0) { return; } string grp = View.GetRowCellValue(currentRow, colGRP).ToString(); GenelDataSet.XGTRow xgtRow = this.genelDataSet.XGT.FindByGRPID(grp, "+"); if (xgtRow.SYS == "M" || xgtRow.SYS == "V") // Grup Modify ise eklenebilir { View.AddNewRow(); View.SetRowCellValue(View.FocusedRowHandle, colGRP, grp); View.SetRowCellValue(View.FocusedRowHandle, colID, ""); View.SetRowCellValue(View.FocusedRowHandle, colSYS, "V"); // User Modify View.UpdateCurrentRow(); View.MakeRowVisible(View.FocusedRowHandle, true); View.ShowEditor(); } }
public void tsbtpcnh(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string roleid, string subsys, string ngaychungtu, string userid, DataTable khach) { try { Frm_phieuthu u = new Frm_phieuthu(); u.myac = new Frm_phieuthu.ac(F.refreshpcnh); u.getactive(a); u.getsub(subsys); u.getroleid(roleid); u.getkhach(khach); u.getuser(userid); u.getdate(ngaychungtu); u.getpt("pcnh"); /*try * {*/ if (a == "1") { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } /*} * catch { }*/ u.ShowDialog(); } catch { MessageBox.Show("Vui lòng chọn phiếu chi ngân hàng trước khi sửa."); } }
public void tsbtpxht(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string roleid, string subsys, string ngaychungtu, string userid, string branchid, DataTable khach, DataTable hang, Boolean noibo) { try { Frm_phieudieuchinh u = new Frm_phieudieuchinh(); if (noibo == false) { u.myac = new Frm_phieudieuchinh.ac(F.refreshpxht); } else { u.myac = new Frm_phieudieuchinh.ac(F.refreshpxhtnb); } u.getactive(a); u.getpt("pxht"); u.getsub(subsys); u.getkhach(khach); u.gethang(hang); u.getroleid(roleid); u.getbranch(branchid); u.getnoibo(noibo); u.getuser(userid); u.getdate(ngaychungtu); if (a == "1") { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } else { try { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "Mã kho").ToString()); } catch { u.getrole(gen.GetString("select Top 1 StockCode from Stock where StockID in (select StockID from MSC_UserJoinStock where UserID='" + userid + "') order by StockCode")); } } u.ShowDialog(); } catch { MessageBox.Show("Vui lòng chọn phiếu nhập hàng thừa trước khi sửa."); } }
public void tsbtpck(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string roleid, string subsys, string ngaychungtu, string userid, string branchid, string tsbt, DataTable khach, DataTable hang) { try { Frm_chuyenkhonb u = new Frm_chuyenkhonb(); u.myac = new Frm_chuyenkhonb.ac(F.refreshxhgbvlpg); u.getactive(a); u.getsub(subsys); u.gethang(hang); u.getkhach(khach); u.getroleid(roleid); if (tsbt == "tsbtpnhgbvlpg") { u.getpt(tsbt); } else { u.getpt("pxhgbvlpg"); } u.getdate(ngaychungtu); u.getuser(userid); u.getbranch(branchid); if (a == "1") { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } else { try { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "Mã kho").ToString()); } catch { u.getrole(gen.GetString("select Top 1 StockCode from Stock where StockID in (select StockID from MSC_UserJoinStock where UserID='" + userid + "') order by StockCode")); } } u.ShowDialog(); } catch { MessageBox.Show("Vui lòng chọn phiếu xuất hàng gửi bán vỏ LPG trước khi sửa."); } }
private void grvTroCapBHXH_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { grvTroCapBHXH.ClearColumnErrors(); DevExpress.XtraGrid.Views.Grid.GridView View = (DevExpress.XtraGrid.Views.Grid.GridView)sender; DevExpress.XtraGrid.Columns.GridColumn ID_CN = View.Columns["ID_CN"]; DevExpress.XtraGrid.Columns.GridColumn NGHI_TU_NGAY = View.Columns["NGHI_TU_NGAY"]; DevExpress.XtraGrid.Columns.GridColumn NGHI_DEN_NGAY = View.Columns["NGHI_DEN_NGAY"]; DevExpress.XtraGrid.Columns.GridColumn ID_LDV = View.Columns["ID_LDV"]; DevExpress.XtraGrid.Columns.GridColumn ID_HTNTC = View.Columns["ID_HTNTC"]; if (View.GetRowCellValue(e.RowHandle, ID_LDV).ToString() == "") { e.Valid = false; View.SetColumnError(ID_LDV, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraLDVNULL", Commons.Modules.TypeLanguage)); return; } if (View.GetRowCellValue(e.RowHandle, ID_HTNTC).ToString() == "") { e.Valid = false; View.SetColumnError(ID_HTNTC, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraHTNTCNULL", Commons.Modules.TypeLanguage)); return; } if (View.GetRowCellValue(e.RowHandle, NGHI_TU_NGAY).ToString() == "") { e.Valid = false; View.SetColumnError(NGHI_TU_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTuNgayCNULL", Commons.Modules.TypeLanguage)); return; } if (View.GetRowCellValue(e.RowHandle, NGHI_DEN_NGAY).ToString() == "") { e.Valid = false; View.SetColumnError(NGHI_DEN_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraDenNgayNULL", Commons.Modules.TypeLanguage)); return; } //kiểm tra dữ liệu trùng DataTable tempt = Commons.Modules.ObjSystems.ConvertDatatable(grvTroCapBHXH); int n = 0; try { string sSql = "SELECT dbo.fuKiemTraTroCapBHXH(" + View.GetRowCellValue(e.RowHandle, ID_CN) + ",'" + Convert.ToDateTime(View.GetRowCellValue(e.RowHandle, NGHI_TU_NGAY)).ToString("MM/dd/yyyy") + "','" + Convert.ToDateTime(View.GetRowCellValue(e.RowHandle, NGHI_DEN_NGAY)).ToString("MM/dd/yyyy") + "'," + ThangdateEdit.DateTime.Month + "," + ThangdateEdit.DateTime.Year + ")"; n = Convert.ToInt32(SqlHelper.ExecuteScalar(Commons.IConnections.CNStr, CommandType.Text, sSql)); } catch { } if (n == 0) { //kiểm tra từ ngày dến ngày trên lưới DateTime tn = Convert.ToDateTime(View.GetRowCellValue(e.RowHandle, NGHI_TU_NGAY)); DateTime dn = Convert.ToDateTime(View.GetRowCellValue(e.RowHandle, NGHI_DEN_NGAY)); n = tempt.AsEnumerable().Count(x => x.Field <Int64>("ID_CN") == Convert.ToInt64(View.GetRowCellValue(e.RowHandle, ID_CN)) && x.Field <DateTime>("NGHI_TU_NGAY") > tn && x.Field <DateTime>("NGHI_DEN_NGAY") < dn); if (n == 1) { e.Valid = false; View.SetColumnError(ID_CN, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgTrungDuLieu", Commons.Modules.TypeLanguage)); View.SetColumnError(NGHI_TU_NGAY, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgTrungDuLieu", Commons.Modules.TypeLanguage)); val = false; return; } } }
public static List <string> GridToCSV(DevExpress.XtraGrid.GridControl grid) { DevExpress.XtraGrid.Views.Grid.GridView view = (DevExpress.XtraGrid.Views.Grid.GridView)grid.DefaultView; Dictionary <int, string> Titles = new Dictionary <int, string>(); List <string> CSV = new List <string>(); StringBuilder sb = new StringBuilder(); Dictionary <int, int> rowSequence = new Dictionary <int, int>(); for (int i = 0; i < view.Columns.Count; i++) { if (view.Columns[i].Visible) { int k = view.Columns[i].VisibleIndex; rowSequence[k] = i; } } for (int key = 0; key < rowSequence.Count; key++) { int i = rowSequence[key]; Titles.Add(i, view.Columns[i].Caption); sb.Append(string.Format("\"{0}\",", Titles[i])); } CSV.Add(RemoveComma(sb.ToString())); int dataRowCount = view.DataRowCount; for (int i = 0; i < dataRowCount; i++) { sb.Length = 0; for (int key = 0; key < rowSequence.Count; key++) { int k = rowSequence[key]; DevExpress.XtraGrid.Columns.GridColumn col = view.Columns[k]; var cellValue = view.GetRowCellValue(i, col); //GetRowCellDisplayText(i, col,); if (cellValue != null) { if (cellValue is DateTime) { DateTime dt = (DateTime)cellValue; sb.Append(string.Format("\"{0}\",", dt.ToShortDateString())); } else { sb.Append(string.Format("\"{0}\",", cellValue.ToString())); } } else { sb.Append(","); } } CSV.Add(RemoveComma(sb.ToString())); } return(CSV); }
private void grvNhom_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView View = (DevExpress.XtraGrid.Views.Grid.GridView)sender; DevExpress.XtraGrid.Columns.GridColumn sTenNhom = View.Columns["TEN_NHOM"]; if (View.GetRowCellValue(e.RowHandle, sTenNhom).ToString() == "") { e.Valid = false; View.SetColumnError(sTenNhom, Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgTenNhomKhongNull", Commons.Modules.TypeLanguage)); XtraMessageBox.Show(Commons.Modules.ObjLanguages.GetLanguage(Commons.Modules.ModuleName, this.Name, "MsgKiemtraTenUserNULL", Commons.Modules.TypeLanguage), "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public void tsbtdeletepctm(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F) { try { string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(); if (gen.GetString("select Posted from CAPayment where RefID='" + name + "'") == "True") { XtraMessageBox.Show("Phiếu đã được ghi sổ không thể xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } if (XtraMessageBox.Show("Bạn có chắc muốn hủy phiếu chi tiền mặt " + view.GetRowCellValue(view.FocusedRowHandle, "Số chứng từ").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { gen.ExcuteNonquery("delete from CAPayment where RefID='" + name + "'"); gen.ExcuteNonquery("delete from CAPaymentDetail where RefID='" + name + "'"); gen.ExcuteNonquery("insert into HACHTOANBK select *,GetDate() from HACHTOAN where RefID='" + name + "'"); gen.ExcuteNonquery("delete HACHTOAN where RefID='" + name + "'"); view.DeleteRow(view.FocusedRowHandle); } } catch { XtraMessageBox.Show("Vui lòng chọn phiếu chi tiền mặt trước khi xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void tsbtpnk(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string roleid, string subsys, string ngaychungtu, string userid, string branchid, DataTable khach, DataTable hang) { try { Frm_phieunhapvo u = new Frm_phieunhapvo(); u.myac = new Frm_phieunhapvo.ac(F.refreshpnkvo); u.getactive(a); u.getsub(subsys); u.getroleid(roleid); u.getkhach(khach); u.gethang(hang); u.getpt("pnk"); u.getdate(ngaychungtu); u.getuser(userid); u.getbranch(branchid); /*try * {*/ if (a == "1") { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } else { try { u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "Mã kho").ToString()); } catch { u.getrole(gen.GetString("select Top 1 StockCode from Stock where StockID in (select StockID from MSC_UserJoinStock where UserID='" + userid + "') order by StockCode")); } } /*} * catch { }*/ u.ShowDialog(); } catch { MessageBox.Show("Vui lòng chọn phiếu nhập kho trước khi sửa."); } }
public void tsbtdeletecsncc(DevExpress.XtraGrid.Views.Grid.GridView view, Form1 F, string userid) { try { userid = gen.GetString("select Top 1 FullName from MSC_User where UserID='" + userid + "'"); if (userid.ToUpper() == view.GetRowCellValue(view.FocusedRowHandle, "Người lập").ToString().ToUpper() || Double.Parse(gen.GetString("select Top 1 AuthenticationType from MSC_User where UserID='" + userid + "'")) > 1) { string name = view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString(); if (XtraMessageBox.Show("Bạn có chắc muốn xóa Chính sách " + view.GetRowCellValue(view.FocusedRowHandle, "Chính sách").ToString() + "?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { gen.ExcuteNonquery("delete from Policy where PolicyID='" + name + "'"); view.DeleteRow(view.FocusedRowHandle); } } else { XtraMessageBox.Show("Bạn không phải người lập chính sách này."); return; } } catch { XtraMessageBox.Show("Vui lòng chọn Chính sách trước khi xóa.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void tsbthttk(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string userid) { /*try * {*/ Frm_account u = new Frm_account(); u.myac = new Frm_account.ac(F.refreshaccount); u.getactive(a); u.getuserid(userid); u.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); u.ShowDialog(); /*} * catch { MessageBox.Show("Vui lòng chọn tài khoản trước khi sửa hoặc thêm."); }*/ }
public void updateUnit() { GridView gridView = grcUnit.FocusedView as GridView; // UnitDTO unitDTO = new UnitDTO(); unitDTO.iMaDVT = (string)gridView.GetRowCellValue(gridView.FocusedRowHandle, "iMaDVT"); unitDTO.iTen = (string)gridView.GetRowCellValue(gridView.FocusedRowHandle, "iTen"); unitDTO.iGhiChu = (string)gridView.GetRowCellValue(gridView.FocusedRowHandle, "iGhiChu"); unitDTO.iActive = (bool)gridView.GetRowCellValue(gridView.FocusedRowHandle, "iActive"); frmUpdateUnit fUnit = new frmUpdateUnit(unitDTO); fUnit.ShowDialog(); if (statusAction == 1) { loadUnit(); statusAction = 0; } else { } }
private void gridViewArticulo_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) { if (e.Row == null) { return; } DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView; GridColumn codigoCol = view.Columns["CODIGO"]; GridColumn codigoArticuloCol = view.Columns["CODIGOARTICULO"]; GridColumn descripcionCol = view.Columns["DESCRIPCION"]; GridColumn precioventaCol = view.Columns["PRECIOVENTA"]; GridColumn impuestoCol = view.Columns["CODIGOIMPUESTO"]; GridColumn tipoArticuloCol = view.Columns["CODIGOTIPOARTICULO"]; //Revisar valores String codigoString = (String)view.GetRowCellValue(e.RowHandle, codigoCol); String descripcionString = (String)view.GetRowCellValue(e.RowHandle, descripcionCol); Decimal precioDbbl = (Decimal)view.GetRowCellValue(e.RowHandle, precioventaCol); long impuestoLong = (long)view.GetRowCellValue(e.RowHandle, impuestoCol); long codigoArticuloLong = (long)view.GetRowCellValue(e.RowHandle, codigoArticuloCol); long tipoArticuloLong = (long)view.GetRowCellValue(e.RowHandle, tipoArticuloCol); // e.Valid = true; if (codigoString == null || codigoString.Equals("")) { e.Valid = false; view.SetColumnError(codigoCol, "Ingrese un código para el producto"); } if (descripcionString == null || descripcionString.Equals("")) { e.Valid = false; view.SetColumnError(descripcionCol, "Ingrese la descripción!"); } if (impuestoLong == 0) { e.Valid = false; view.SetColumnError(impuestoCol, "Seleccione un impuesto!"); } if (impuestoLong == 0) { e.Valid = false; view.SetColumnError(tipoArticuloCol, "Seleccione un un tipo e producto!"); } if (this.articuloservicio.getArticulo(CredencialUsuario.getInstancia().getEmpresaSeleccionada().CODIGOEMPRESA, codigoString, codigoArticuloLong) != null) { e.Valid = false; view.SetColumnError(codigoCol, "Código " + codigoString + " ya se encuentra definido."); } if (this.articuloservicio.getArticuloDes(CredencialUsuario.getInstancia().getEmpresaSeleccionada().CODIGOEMPRESA, descripcionString, codigoArticuloLong) != null) { e.Valid = false; view.SetColumnError(codigoCol, "Producto: " + descripcionString + " ya se encuentra definido."); } }
public void tsbtckkh(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string ngay) { try { Depreciation m = new Depreciation(); m.myac = new Depreciation.ac(F.refreshckkh); m.getactive(a); m.getngay(ngay); if (a == "1") { m.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } m.ShowDialog(); } catch { MessageBox.Show("Vui lòng chọn Tài sản khấu hao trước khi sửa."); } }
public void tsbttgp(string a, Form1 F, DevExpress.XtraGrid.Views.Grid.GridView view, string ngay) { try { Frm_Descasc m = new Frm_Descasc(); m.myac = new Frm_Descasc.ac(F.refreshtgp); m.getactive(a); m.getngay(ngay); if (a == "1") { m.getrole(view.GetRowCellValue(view.FocusedRowHandle, "ID").ToString()); } m.ShowDialog(); } catch { MessageBox.Show("Vui lòng chọn Chi phí trước khi sửa."); } }
private void gridView3_MasterRowExpanding(object sender, DevExpress.XtraGrid.Views.Grid.MasterRowCanExpandEventArgs e) { DevExpress.XtraGrid.Views.Grid.GridView view = sender as DevExpress.XtraGrid.Views.Grid.GridView; if ((int)view.GetRowCellValue(e.RowHandle, view.Columns["IdPresupDet"]) < 0) { MessageBox.Show("No puede crear subdetalles antes de guardar los cambios en el Detalle", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); e.Allow = false; } //else if (view.GetDetailView(e.RowHandle, e.RelationIndex).RowCount == 0) // { // MessageBox.Show("Si crea un subdetalles la cantidad y precio del detalle actual serán eliminados y el total se reemplazara por el total de los subdetalles creados", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // } }