private void fdoSave() { if (fValidate()) { DataTable tmpPN = new modPhieuNX().dtPhieuNX(); DataRow vR = tmpPN.NewRow(); vR["Phieunxid"] = pPhieuNXID; vR["Sophieu"] = txtSophieu.Text.ToUpper(); vR["Loaiphieu"] = this.pLoaiPhieu; vR["Makho"] = txtMaKho.Text; vR["Mald"] = txtMald.Text; vR["Makh"] = txtMadv.Text; vR["Ngayct"] = Convert.ToDateTime(dtpNgaylap.Text); vR["Ngayps"] = Convert.ToDateTime(dtpNgayPS.Text); vR["Soctgoc"] = txtSoctgoc.Text; vR["Loaitien"] = cbNguyente.Text.ToString(); vR["Tygia"] = txtTygia.Text.Length == 0 ? 0 : Double.Parse(txtTygia.Text); vR["Nguyente"] = 0; vR["Vat"] = 0; vR["TTVat"] = 0; vR["Thanhtien"] = 0; vR["Ghichu"] = txtGhichu.Text; vR["Giaonhan"] = txtNguoigiao.Text.Trim(); vR["Ngaylap"] = DateTime.Now; vR["Nguoilap"] = MTGlobal.MT_USER_LOGIN; tmpPN.Rows.Add(vR); tmpPN.AcceptChanges(); DataTable tmpPNCT = new modPhieuNX().dtPhieuNXCT(); var filteredRows = gvPhieuXuat.DataController.GetAllFilteredAndSortedRows(); if (filteredRows.Count == 0) { return; } // gvPhieuXuat.CommitEditing(); gvPhieuXuat.CloseEditor(); otblPNXCT.AcceptChanges(); //for (int i = 0; i < filteredRows.Count; i++){ for (int i = 0; i < gvPhieuXuat.DataRowCount; i++) { DataRow cR = tmpPNCT.NewRow(); foreach (GridColumn column in gvPhieuXuat.VisibleColumns) { cR[column.FieldName] = gvPhieuXuat.GetRowCellValue(i, column); } cR["Phieunxctid"] = gvPhieuXuat.GetRowCellValue(i, colPhieunxctid); cR["Phieunxid"] = pPhieuNXID; //cR["Maspid"] = sR["Maspid"]; //cR["Masp"] = sR["Masp"]; //cR["Tensp"] = sR["Tensp"]; //cR["Quycach"] = sR["Quycach"]; //cR["Dvt"] = sR["Dvt"]; //cR["SLThung"] = sR["SLThung"]; //cR["Soluong"] = sR["Soluong"]; //cR["Dongia"] = sR["Dongia"]; //cR["Nguyente"] = sR["Nguyente"]; //cR["Vat"] = sR["Vat"]; //cR["TTVat"] = sR["TTVat"]; //cR["Thanhtien"] = sR["Thanhtien"]; cR["Songaychono"] = 0; cR["Ghiso"] = 1; tmpPNCT.Rows.Add(cR); } tmpPNCT.AcceptChanges(); String Rs = new modPhieuNX().SavePhieuNX(tmpPN, tmpPNCT); if (Rs == "") { setReadOnly(true); MTGlobal.SetToolStripButtonAction(pACT_ROLE, MTButton, "SAVE"); SysPar.SetGridReadOnly(true, gvPhieuXuat); isEdit = false; } else { Utils.showMessage(Rs, "Thông báo"); } } }
private void fdoSave() { if (fValidate()) { DataTable tmpPN = new modPhieuNX().dtPhieuNX(); DataRow vR = tmpPN.NewRow(); vR["Phieunxid"] = pPhieuNXID; vR["Sophieu"] = txtSophieu.Text.ToUpper(); vR["Loaiphieu"] = this.pLoaiPhieu; vR["Makho"] = txtMakho.Text; vR["Mald"] = txtMald.Text; vR["Makh"] = txtMadv.Text; vR["Ngayct"] = Convert.ToDateTime(dtpNgaylap.Text); vR["Ngayps"] = Convert.ToDateTime(dtpNgayPS.Text); vR["Soctgoc"] = txtSoctgoc.Text; vR["Loaitien"] = cbNguyente.Text.ToString(); vR["Tygia"] = txtTygia.Text.Length == 0 ? 0 : Double.Parse(txtTygia.Text); vR["Nguyente"] = 0; vR["Vat"] = 0; vR["TTVat"] = 0; vR["Thanhtien"] = 0; vR["Ghichu"] = txtGhichu.Text; vR["Giaonhan"] = txtNguoinhan.Text; vR["Ngaylap"] = DateTime.Now; vR["Nguoilap"] = MTGlobal.MT_USER_LOGIN; vR["TKNo"] = txtTKNo.Text.ToString().Trim(); vR["TKCo"] = txtTKCo.Text.ToString().Trim(); tmpPN.Rows.Add(vR); tmpPN.AcceptChanges(); DataTable tmpPNCT = new modPhieuNX().dtPhieuNXCT(); var filteredRows = tblView.Grid.DataController.GetAllFilteredAndSortedRows(); if (filteredRows.Count == 0) { return; } tblView.CommitEditing(); tblView.CloseEditor(); otblPNXCT.AcceptChanges(); foreach (DataRow sR in otblPNXCT.Rows) { DataRow cR = tmpPNCT.NewRow(); cR["Phieunxctid"] = sR["phieunxctid"]; cR["Phieunxid"] = pPhieuNXID; cR["Maspid"] = sR["Maspid"]; cR["Masp"] = sR["Masp"]; cR["Tensp"] = sR["Tensp"]; cR["Quycach"] = sR["Quycach"]; cR["Dvt"] = sR["Dvt"]; cR["SLThung"] = sR["SLThung"]; cR["Soluong"] = sR["Soluong"]; cR["Dongia"] = sR["Dongia"]; cR["Nguyente"] = sR["Nguyente"]; cR["Vat"] = sR["Vat"]; cR["TTVat"] = sR["TTVat"]; cR["Thanhtien"] = sR["Thanhtien"]; cR["Songaychono"] = 0; cR["Ghiso"] = 1; cR["Ghichu"] = sR["Ghichu"]; tmpPNCT.Rows.Add(cR); } tmpPNCT.AcceptChanges(); String Rs = new modPhieuNX().SavePhieuNX(tmpPN, tmpPNCT); if (Rs == "") { setReadOnly(true); MTGlobal.SetButtonAction(pACT_ROLE, MTButton, "SAVE"); MTGlobal.SetGridReadOnly(grdPhieuNhap, tblView, true); isEdit = false; } else { Utils.showMessage(Rs, "Thông báo"); } } }