private void GenerateGui() { po poMain = poList[tabControl1.SelectedIndex]; PoState poState = poStateList.GetPoStateAccordingToValue((int)poMain.poStates); if (poState.WhoCanUpdate().Contains(UserInfo.Job)) { tsbUpdate.Enabled = true; } else { tsbUpdate.Enabled = false; } //for list tscbStateList.Items.Clear(); List <Operation> opList = poState.GetOperationList(); foreach (Operation op in opList) { if (op.jobs.Contains(UserInfo.Job)) { tscbStateList.Items.Add(op.operationName); } } }
public void FillTheTable(po poMain) { this.poId = poMain.poId; tbVendor.Text = poMain.vendorName; tbContact.Text = poMain.contact; cbPa.SelectedItem = buyerIdsAndNames[poMain.pa.Value]; tbVendorNumber.Text = poMain.vendorNumber; tbPoDate.Text = poMain.poDate.Value.ToShortDateString(); tbPoNo.Text = poMain.poNo; tbFreight.Text = poMain.freight; tbShipMethod.Text = poMain.shipMethod; tbPaymentTerms.Text = poMain.paymentTerms; tbShipToLocation.Text = poMain.shipToLocation; tbBillTo.Text = poMain.billTo; tbShipTo.Text = poMain.shipTo; foreach (poitems itemDb in PoMgr.PoMgr.GetPoItemsAccordingToPoId(poMain.poId)) { poItemsStateList.Add(new PoItemContentAndState { poItem = itemDb, state = OrderItemsState.Normal } ); } FillTheDataGridPoItems(); }
public PoView(po poMain) { InitializeComponent(); poList = new List <po>(); poList.Add(poMain); this.Text = "PO Info for PO:" + poMain.poId; }
private void GenerateGui() { po poMain = poList[tabControl1.SelectedIndex]; if (poMain.poStates != (int)PoStatesEnum.New && UserCombine.GetUserCanBeBuyerMananger().Contains((int)UserInfo.Job)) { tsbUpdate.Enabled = true; } else if (poMain.poStates == (int)PoStatesEnum.New && UserCombine.GetUserCanBeBuyers().Contains((int)UserInfo.Job)) { tsbUpdate.Enabled = true; } else { tsbUpdate.Enabled = false; } //for approve and rejected. if (poMain.poStates == (int)PoStatesEnum.New) { tsbApprove.Enabled = true; tsbReject.Enabled = true; } else { tsbApprove.Enabled = false; tsbReject.Enabled = false; } //for cancel if (poMain.poStates == (int)PoStatesEnum.Approved) { tsbCancel.Enabled = true; } else { tsbCancel.Enabled = false; } if (UserInfo.Job == JobDescription.Admin || UserInfo.Job == JobDescription.Boss) { tsbForceClose.Enabled = true; } else { tsbForceClose.Enabled = false; } if (!UserCombine.GetUserCanBeBuyerMananger().Contains((int)UserInfo.Job)) { tsbApprove.Enabled = false; tsbReject.Enabled = false; tsbCancel.Enabled = false; tsbForceClose.Enabled = false; } }
private void tsbCancel_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show("Cancel PO?", "", MessageBoxButtons.YesNo)) { po po = poList[tabControl1.SelectedIndex]; PoMgr.PoMgr.WholeUpdatePoState(po.poId, (int)PoStatesEnum.Cancel); this.DialogResult = DialogResult.Yes; this.Close(); } }
private void tsbForceClose_Click(object sender, EventArgs e) { if (DialogResult.Yes == MessageBox.Show("Close PO and all its Items?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2)) { po po = poList[tabControl1.SelectedIndex]; PoMgr.PoMgr.WholeUpdatePoState(po.poId, (int)PoStatesEnum.Closed); this.DialogResult = DialogResult.Yes; this.Close(); } }
public void PoUpdate() { if (false == CheckValues()) { return; } po poMain = GetValues(); PoMgr.PoMgr.UpdatePo(poMain); MessageBox.Show("Update Purchase Order Successfully"); }
private void tsbToDocx_Click(object sender, EventArgs e) { List <PoItemContentAndState> poItemsList = poViewControlList[tabControl1.SelectedIndex].GetPoItemsStateList(); po po = poList[tabControl1.SelectedIndex]; if (UserInfo.Job == JobDescription.Sales || UserInfo.Job == JobDescription.SalesManager) { po.vendorName = ""; po.contact = ""; } SoPoDocxHelper.SavePoDocx(po, poItemsList); }
private void tsbSave_Click(object sender, EventArgs e) { po poMain = poViewControl1.GetValues(); poMain.soId = this.soId; poMain.poStates = (sbyte)new PoNew().GetStateValue(); poMain.poDate = DateTime.Now; PoMgr.PoMgr.SavePoMain(poMain); int poId = PoMgr.PoMgr.GetTheInsertId(UserInfo.UserId); List <PoItemContentAndState> items = poViewControl1.GetPoItemContentAndSate(); foreach (PoItemContentAndState pics in items) { pics.poItem.poId = poId; } PoMgr.PoMgr.UpDatePoItems(items); this.Close(); }
public void PoUpdate() { if (false == CheckValues()) { return; } po poMain = GetValues(); PoMgr.PoMgr.UpdatePo(poMain); PoMgr.PoMgr.UpDatePoItems(poItemsStateList); foreach (PoItemContentAndState pics in deletedList) { PoMgr.PoMgr.DeletePoItembyPoItemId(pics.poItem.PoItemsId); } MessageBox.Show("Update Purchase Order Successfully"); }
public void PoSave() { if (false == CheckValues()) { return; } po poMain = GetValues(); poMain.poDate = DateTime.Now; PoMgr.PoMgr.SavePoMain(poMain); int poId = PoMgr.PoMgr.GetTheInsertId((int)poMain.pa); foreach (PoItemContentAndState pics in poItemsStateList) { pics.poItem.poId = poId; } PoMgr.PoMgr.UpDatePoItems(poItemsStateList); MessageBox.Show("Save Purchase Order Successfully"); }
private void tscbStateList_SelectedIndexChanged(object sender, EventArgs e) { if (MessageBox.Show("Change the state to " + (string)tscbStateList.SelectedItem + "?", "warning", MessageBoxButtons.YesNo) == DialogResult.No) { return; } string selectedItemString = (string)tscbStateList.SelectedItem; po poMain = poList[tabControl1.SelectedIndex]; PoState poState = poStateList.GetPoStateAccordingToValue((int)poMain.poStates); foreach (Operation op in poState.GetOperationList()) { if (selectedItemString == op.operationName) { op.operationMethod(poMain.poId); } } this.DialogResult = DialogResult.Yes; }
static void FillThePoSheet(ISheet sheet, po po, List <PoItemContentAndState> poitemList) { AmbleClient.Admin.AccountMgr.AccountMgr accMgr = new Admin.AccountMgr.AccountMgr(); sheet.GetRow(0).CreateCell(2).SetCellValue(po.vendorName); sheet.GetRow(0).CreateCell(9).SetCellValue(po.contact); if (po.pa != null) { sheet.GetRow(0).CreateCell(14).SetCellValue(accMgr.GetNameById((int)po.pa.Value)); } sheet.GetRow(1).CreateCell(2).SetCellValue(po.vendorNumber); if (po.poDate != null) { sheet.GetRow(1).CreateCell(5).SetCellValue(po.poDate.Value.ToShortDateString()); } sheet.GetRow(1).CreateCell(9).SetCellValue(po.poNo); sheet.GetRow(1).CreateCell(14).SetCellValue(po.paymentTerms); sheet.GetRow(2).CreateCell(2).SetCellValue(po.shipMethod); sheet.GetRow(2).CreateCell(9).SetCellValue(po.freight); sheet.GetRow(2).CreateCell(14).SetCellValue(po.shipToLocation); IRow row = sheet.CreateRow(4); row.CreateCell(0).SetCellValue(po.billTo); row.CreateCell(10).SetCellValue(po.shipTo); int itemRowIndex = 9; int totalQty = 0; float totalTotal = 0; int totalQtyRecd = 0; foreach (PoItemContentAndState pcs in poitemList) { IRow itemRow = sheet.CreateRow(itemRowIndex); itemRow.CreateCell(0).SetCellValue(poitemList.IndexOf(pcs) + 1); itemRow.CreateCell(1).SetCellValue(pcs.poItem.partNo); itemRow.CreateCell(2).SetCellValue(pcs.poItem.mfg); itemRow.CreateCell(3).SetCellValue(pcs.poItem.dc); itemRow.CreateCell(4).SetCellValue(pcs.poItem.vendorIntPartNo); itemRow.CreateCell(5).SetCellValue(pcs.poItem.org); itemRow.CreateCell(6).SetCellValue(pcs.poItem.qty.Value); totalQty += pcs.poItem.qty.Value; if (pcs.poItem.qtyRecd != null) { itemRow.CreateCell(7).SetCellValue(pcs.poItem.qtyRecd.Value); totalQtyRecd += pcs.poItem.qtyRecd.Value; } if (pcs.poItem.qtyCorrected != null) { itemRow.CreateCell(8).SetCellValue(pcs.poItem.qtyCorrected.Value); } if (pcs.poItem.qtyAccept != null) { itemRow.CreateCell(9).SetCellValue(pcs.poItem.qtyAccept.Value); } if (pcs.poItem.qtyRejected != null) { itemRow.CreateCell(10).SetCellValue(pcs.poItem.qtyRejected.Value); } if (pcs.poItem.qtyRTV != null) { itemRow.CreateCell(11).SetCellValue(pcs.poItem.qtyRTV.Value); } if (pcs.poItem.qcPending != null) { itemRow.CreateCell(12).SetCellValue(pcs.poItem.qcPending.Value); } itemRow.CreateCell(13).SetCellValue(Enum.GetName(typeof(AmbleClient.Currency), pcs.poItem.currency)); itemRow.CreateCell(14).SetCellValue(pcs.poItem.unitPrice.Value); itemRow.CreateCell(15).SetCellValue(pcs.poItem.qty.Value * pcs.poItem.unitPrice.Value); totalTotal += pcs.poItem.qty.Value * pcs.poItem.unitPrice.Value; if (pcs.poItem.dueDate != null) { itemRow.CreateCell(16).SetCellValue(pcs.poItem.dueDate.Value.ToShortDateString()); } if (pcs.poItem.receiveDate != null) { itemRow.CreateCell(17).SetCellValue(pcs.poItem.receiveDate.Value.ToShortDateString()); } itemRow.CreateCell(18).SetCellValue(pcs.poItem.stepCode); itemRow.CreateCell(19).SetCellValue("Unknown"); itemRowIndex++; IRow infoRow = sheet.CreateRow(itemRowIndex); infoRow.CreateCell(1).SetCellValue("Note To Vendor >>" + pcs.poItem.noteToVendor); sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(itemRowIndex, itemRowIndex, 1, 16)); itemRowIndex++; } //add total bar IRow totalRow = sheet.CreateRow(itemRowIndex); sheet.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(itemRowIndex, itemRowIndex, 0, 4)); totalRow.CreateCell(5).SetCellValue("Total"); totalRow.CreateCell(6).SetCellValue(totalQty); totalRow.CreateCell(7).SetCellValue(totalQtyRecd); totalRow.CreateCell(15).SetCellValue(totalTotal); }
public void ProcessParallelThread() { // Get all PDF -> _mdr var Files = FolderPO.GetAllFile(FolderPO.tmpFolder, "pdf"); dnbmssqlEntities db = new dnbmssqlEntities(); foreach (var xFile in Files) { try { #region Convert FileInfo to PDF Object // Split PDF Filename into Object var pdf = SplitPdf(xFile); #endregion #region FTP Processes // Set ftp values var ftp = new ftp(@"ftp://188.121.43.20/services.danubeco.com/", "supplier"); // Upload PDF using FTP to Server Folder -> supplierx var result = ftp.Upload(Path.Combine("supplier", xFile.Name), Path.Combine(FolderPO.tmpFolder, xFile.Name)); if (result.Success) { #region Set PO Object // ----------------------------------------------- PO --------------------------------------------------------- var newPO = new po { sid = pdf.sid, pono = pdf.pono, region = pdf.region, location = pdf.location, division = pdf.division, link = xFile.Name, filestatus = "Available", released = DateTime.Now.ToString("yyyy-MM-dd"), expiration = DateTime.Now.AddDays(7).ToString("yyyy-MM-dd"), isexpired = "no" }; #endregion #region Store PO Object in Database var isExist = db.poes.FirstOrDefault(p => p.pono.Equals(newPO.pono)); if (isExist != null) { isExist.filestatus = "Updated"; isExist.link = newPO.link; } else { db.poes.Add(newPO); } #endregion #region Set SMS // ----------------------------------------------- SMS --------------------------------------------------------- var isExists = db.sms.FirstOrDefault(x => x.sid.Equals(newPO.sid) && x.region.Equals(newPO.region)); if (isExists == null) { var user = db.supplierregions.FirstOrDefault(s => s.sid.Equals(newPO.sid) && s.region.Equals(newPO.region)); if (user != null) { if (user.sms.Equals("y")) { db.sms.Add(new sm { sid = newPO.sid, region = newPO.region, icurrent = user.mobile, timesent = DateTime.Now.ToString(), status = "waiting" }); } } } #endregion #region Store & Backup File + Log // save changes to Database db.SaveChanges(); // move files to backup folder FolderPO.moveToBckFolder(xFile); // write log ni rtbox updateLog(xFile, "Success", Color.Green); #endregion } else { #region Backup File + Log // move to error folder FolderPO.moveToErrFolder(xFile); updateLog(xFile, "ErrorFTP", Color.Red); #endregion } #endregion } catch (Exception ex) { // move to error folder FolderPO.moveToErrFolder(xFile); updateLog(xFile, "ErrorFile" + ex.Message, Color.Red); } } }
public static void SavePoDocx(po po, List <PoItemContentAndState> poitemsList) { document = DocX.Load(@"PoDocx.dll"); Formatting format = new Formatting(); format.FontFamily = new System.Drawing.FontFamily("Arial"); format.Size = 9; Table soTable = document.Tables[0]; soTable.Rows[0].Cells[1].Paragraphs[0].InsertText(po.vendorName, false, format); soTable.Rows[0].Cells[3].Paragraphs[0].InsertText(Tool.Get6DigitalNumberAccordingToId(po.poId), false, format); soTable.Rows[1].Cells[3].Paragraphs[0].InsertText((po.poDate.Year + "-" + po.poDate.Month + "-" + po.poDate.Day).ToString(), false, format); soTable.Rows[2].Cells[3].Paragraphs[0].InsertText(po.paymentTerms, false, format); soTable.Rows[3].Cells[1].Paragraphs[0].InsertText(po.contact, false, format); //soTable.Rows[4].Cells[3].Paragraphs[0].InsertText(po.freight, false, format); soTable.Rows[4].Cells[1].Paragraphs[0].InsertText(AllAccountInfo.GetNameAccordingToId(po.pa), false, format); custvendorinfo custven = CustVenInfoManager.GetUniqueCustVenInfo(1, po.vendorName, UserInfo.UserId); if (custven != null) { soTable.Rows[1].Cells[1].Paragraphs[0].InsertText(custven.phone1, false, format); soTable.Rows[2].Cells[1].Paragraphs[0].InsertText(custven.fax, false, format); } Table itemTable = document.Tables[1]; if (poitemsList.Count > 2) { Row sampleRow = itemTable.Rows[2]; for (int i = 0; i < poitemsList.Count - 2; i++) { itemTable.InsertRow(sampleRow, 3); } } float totalAmount = 0; for (int i = 0; i < poitemsList.Count; i++) { itemTable.Rows[i + 2].Cells[0].Paragraphs[0].InsertText((i + 1).ToString(), false, format); itemTable.Rows[i + 2].Cells[1].Paragraphs[0].InsertText(poitemsList[i].poItem.partNo, false, format); itemTable.Rows[i + 2].Cells[2].Paragraphs[0].InsertText(poitemsList[i].poItem.mfg, false, format); itemTable.Rows[i + 2].Cells[3].Paragraphs[0].InsertText(poitemsList[i].poItem.qty.ToString(), false, format); //itemTable.Rows[i+2].Cells[4].Paragraphs[0].InsertText(poitemsList[i].poItem.cr if (poitemsList[i].poItem.currency == (int)Currency.USD) { itemTable.Rows[i + 2].Cells[5].Paragraphs[0].InsertText(poitemsList[i].poItem.unitPrice.ToString(), false, format); itemTable.Rows[i + 2].Cells[6].Paragraphs[0].InsertText((poitemsList[i].poItem.unitPrice * poitemsList[i].poItem.qty).ToString(), false, format); } else { itemTable.Rows[i + 2].Cells[5].Paragraphs[0].InsertText(poitemsList[i].poItem.unitPrice.ToString() + Enum.GetName(typeof(Currency), poitemsList[i].poItem.currency), false, format); itemTable.Rows[i + 2].Cells[6].Paragraphs[0].InsertText((poitemsList[i].poItem.unitPrice * poitemsList[i].poItem.qty).ToString() + Enum.GetName(typeof(Currency), poitemsList[i].poItem.currency), false, format); } if (poitemsList[i].poItem.unitPrice.HasValue) { totalAmount += poitemsList[i].poItem.unitPrice.Value * poitemsList[i].poItem.qty; } } itemTable.Rows[itemTable.Rows.Count - 1].Cells[6].Paragraphs[0].InsertText(totalAmount.ToString(), false, format); WriteToFile(); }
public PoView(po poMain) { InitializeComponent(); poList = new List <po>(); poList.Add(poMain); }
public void FillTheTable(po poMain, int?selectedItem) { this.poId = poMain.poId; this.selectedPoItemId = selectedItem; if (UserInfo.Job == JobDescription.Sales || UserInfo.Job == JobDescription.SalesManager) { tbVendor.Text = ""; tbContact.Text = ""; } else { tbVendor.Text = poMain.vendorName; tbContact.Text = poMain.contact; } if (buyerIdsAndNames.Keys.Contains(poMain.pa)) { cbPa.SelectedItem = buyerIdsAndNames[poMain.pa]; } else { cbPa.Items.Clear(); cbPa.Items.Add(AmbleClient.Admin.AccountMgr.AccountMgr.GetNameById(poMain.pa)); cbPa.SelectedIndex = 0; } tbVendorNumber.Text = poMain.vendorNumber; tbPoDate.Text = poMain.poDate.ToShortDateString(); tbPoNo.Text = Tool.Get6DigitalNumberAccordingToId(poMain.poId); cbFreight.Text = poMain.freight; tbShipMethod.Text = poMain.shipMethod; tbPaymentTerms.Text = poMain.paymentTerms; tbShipToLocation.Text = poMain.shipToLocation; tbBillTo.Text = poMain.billTo; tbShipTo.Text = poMain.shipTo; GetPoItemsList(); FillTheDataGridPoItems(); if (mysubs.Contains(poMain.pa)) { btAdd.Enabled = true; btDelete.Enabled = true; btSplit.Enabled = true; } else { btAdd.Enabled = false; btDelete.Enabled = false; btSplit.Enabled = false; } if (poMain.poStates != (sbyte)PoStatesEnum.New) { btAdd.Enabled = false; } else { btAdd.Enabled = true; } }