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 checksau(string sct, int vt, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, Frm_hoadonxhgb F, string ngay, string branchid, string ledv) { try { ledv = gen.GetString("select * from Stock where StockCode='" + ledv + "'"); tsbttruoc.Enabled = true; string id; if (vt == 0) { id = gen.GetString("select Top 1 * from SSInvoiceBranch where RefNo > '" + sct + "' and Month(PURefDate)='" + DateTime.Parse(ngay).Month.ToString() + "' and Year(PURefDate)='" + DateTime.Parse(ngay).Year.ToString() + "' and BranchID='" + branchid + "' and StockID='" + ledv + "' order by RefNo ASC"); } else { id = gen.GetString("select Top 1 * from SSInvoiceBranch where RefNo > '" + sct + "' and Month(PURefDate)='" + DateTime.Parse(ngay).Month.ToString() + "' and Year(PURefDate)='" + DateTime.Parse(ngay).Year.ToString() + "' and BranchID='" + branchid + "' and StockID='" + ledv + "' order by RefNo DESC"); tsbtsau.Enabled = false; } F.getrole(id); } catch { tsbtsau.Enabled = false; } }
public void checkpck(string active, string role, Frm_hoadonxhgb F, GridView gridView1, LookUpEdit ledt, LookUpEdit ledv, TextEdit txtsct, TextEdit txtname, TextEdit txtdc, TextEdit txtldn, DateEdit denct, DateEdit denht, string ngaychungtu, ComboBoxEdit cbthue, string userid, string branchid, TextEdit txtms, TextEdit txtkhhd, TextEdit txtshd, TextEdit txtnhd, TextEdit txthtt, TextEdit txthttt, TextEdit txtthue, ToolStripSplitButton tsbttruoc, ToolStripSplitButton tsbtsau, TextEdit txtquyen, LookUpEdit ledvx) { try { string dt = gen.GetString("select * from AccountingObject where AccountingObjectCode='" + ledt.EditValue.ToString() + "'"); string[,] detail = new string[20, 8]; string check = "0"; for (int i = 0; i < gridView1.RowCount - 1; i++) { if (gridView1.GetRowCellValue(i, "Mã hàng").ToString() == "") { check = "1"; } else { string mh = gen.GetString("select * from InventoryItem where InventoryItemCode='" + gridView1.GetRowCellValue(i, "Mã hàng").ToString() + "'"); detail[i, 0] = mh; } if (gridView1.GetRowCellValue(i, "Số lượng").ToString() == "") { detail[i, 1] = "0"; } else { detail[i, 1] = gridView1.GetRowCellValue(i, "Số lượng").ToString().Replace(".", "").Replace(",", "."); } if (gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString() == "") { check = "1"; } detail[i, 2] = gridView1.GetRowCellValue(i, "Số lượng quy đổi").ToString().Replace(".", "").Replace(",", "."); if (gridView1.GetRowCellValue(i, "Đơn giá").ToString() == "") { check = "1"; } detail[i, 4] = gridView1.GetRowCellValue(i, "Đơn giá").ToString().Replace(".", "").Replace(",", "."); if (gridView1.GetRowCellValue(i, "Thành tiền").ToString() == "") { check = "1"; } detail[i, 5] = gridView1.GetRowCellValue(i, "Thành tiền").ToString().Replace(".", ""); if (gridView1.GetRowCellValue(i, "Chi phí").ToString() == "") { detail[i, 6] = "0"; } else { detail[i, 6] = gridView1.GetRowCellValue(i, "Chi phí").ToString().Replace(".", ""); } } if (check == "1") { DevExpress.XtraEditors.XtraMessageBox.Show("Vui lòng kiểm tra lại dữ liệu <Mã hàng> <Số lượng quy đổi> <Đơn giá> <Thành tiền> !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { string dv = gen.GetString("select * from Stock where StockCode='" + ledv.EditValue.ToString() + "'"); string dvx = gen.GetString("select * from Stock where StockCode='" + ledvx.EditValue.ToString() + "'"); string tongtien = gridView1.Columns["Thành tiền"].SummaryText.Replace(".", ""); string chiphi = gridView1.Columns["Chi phí"].SummaryText.Replace(".", ""); Double tongcong = Double.Parse(tongtien) + Double.Parse(chiphi); if (active == "0") { try { string ton = gen.GetString("select * from SSInvoiceBranch where RefNo='" + txtsct.Text + "'"); themsct(ngaychungtu, txtsct, ledv.EditValue.ToString(), branchid, tsbttruoc, tsbtsau); XtraMessageBox.Show("Số phiếu trùng, hệ thống tự động chỉnh số phiếu của bạn thành " + txtsct.Text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { } gen.ExcuteNonquery("insert into SSInvoiceBranch(RefID,BranchID,RefType,PURefDate,PUPostedDate,RefNo,AccountingObjectID,AccountingObjectName,AccountingObjectAddress,PUJournalMemo,Posted,TotalAmount,Tax,InvSeries,InvNo,DueDateTime,TotalFreightAmount,UserID,CABARefDate,No,PayNo,TotalVatAmount,StockID,ParalellRefNo,AccountingObjectID1562) values(newid(),'" + branchid + "',101,'" + denct.EditValue.ToString() + "','" + denht.EditValue.ToString() + "','" + txtsct.Text + "','" + dt + "',N'" + txtname.Text + "',N'" + txtdc.Text + "',N'" + txtldn.Text + "','False','" + tongtien + "','" + cbthue.Text + "','" + txtkhhd.Text + "','" + txtshd.Text + "','" + txthtt.Text + "','" + chiphi + "','" + userid + "','" + txtnhd.EditValue.ToString() + "','" + txtms.Text + "',N'" + txthttt.Text + "','" + txtthue.Text.Replace(".", "") + "','" + dv + "','" + txtquyen.Text + "','" + dvx + "')"); string refid = gen.GetString("select * from SSInvoiceBranch where RefNo='" + txtsct.Text + "'"); F.getrole(refid); gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtsct.Text + "','1368','51112','" + tongcong.ToString() + "','" + dt + "','" + dvx + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')"); gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + refid + "','" + txtsct.Text + "','1368','33311','" + txtthue.Text.Replace(".", "") + "','" + dt + "','" + dvx + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')"); for (int i = 0; i < gridView1.RowCount - 1; i++) { gen.ExcuteNonquery("insert into SSInvoiceBranchDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,UnitPrice,Amount,FreightAmount) values(newid(),'" + refid + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "','" + detail[i, 4] + "','" + detail[i, 5] + "','" + detail[i, 6] + "')"); } } else { gen.ExcuteNonquery("update SSInvoiceBranch set PURefDate='" + denct.EditValue.ToString() + "',PUPostedDate='" + denht.EditValue.ToString() + "',AccountingObjectID='" + dt + "',AccountingObjectName=N'" + txtname.Text + "', AccountingObjectAddress=N'" + txtdc.Text + "',PUJournalMemo=N'" + txtldn.Text + "',TotalAmount='" + tongtien + "',Tax='" + cbthue.Text + "',InvSeries='" + txtkhhd.Text + "',InvNo='" + txtshd.Text + "',DueDateTime=" + txthtt.Text + ",TotalFreightAmount='" + chiphi + "',UserID='" + userid + "',CABARefDate='" + txtnhd.EditValue.ToString() + "',No='" + txtms.Text + "',PayNo=N'" + txthttt.Text + "',TotalVatAmount='" + txtthue.Text.Replace(".", "") + "',StockID='" + dv + "',ParalellRefNo='" + txtquyen.Text + "',AccountingObjectID1562='" + dvx + "' where RefID='" + role + "'"); gen.ExcuteNonquery("delete from SSInvoiceBranchDetail where RefID='" + role + "'"); gen.ExcuteNonquery("delete HACHTOAN where RefID='" + role + "'"); gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtsct.Text + "','1368','51112','" + tongcong.ToString() + "','" + dt + "','" + dvx + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')"); gen.ExcuteNonquery("insert into HACHTOAN(RefDeteail,RefID,RefNo,DebitAccount,CreditAccount,Amount,AccountingObjectID,StockID,JournalMemo,RefDate,AccountingObjectIDMain) values(newid(),'" + role + "','" + txtsct.Text + "','1368','33311','" + txtthue.Text.Replace(".", "") + "','" + dt + "','" + dvx + "',N'" + txtldn.Text + "','" + denct.EditValue.ToString() + "','" + dt + "')"); for (int i = 0; i < gridView1.RowCount - 1; i++) { gen.ExcuteNonquery("insert into SSInvoiceBranchDetail(RefDetailID,RefID,Quantity,QuantityConvert,SortOrder,InventoryItemID,UnitPrice,Amount,FreightAmount) values(newid(),'" + role + "','" + detail[i, 1] + "','" + detail[i, 2] + "'," + i + ",'" + detail[i, 0] + "','" + detail[i, 4] + "','" + detail[i, 5] + "','" + detail[i, 6] + "')"); } } F.myac(); F.getactive("1"); F.Text = "Xem phiếu hóa đơn xuất hàng gửi bán"; } } catch { XtraMessageBox.Show("Vui lòng chọn đối tượng trước khi lưu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }