private void OK_Click(object sender, EventArgs e) { MetroGrid grid = sender as MetroGrid; if (grid.SelectedRows.Count > 0) { List <POLineModel> lines = new List <POLineModel>(); //grid.SelectedRows.DataBoundItem; foreach (DataGridViewRow item in grid.Rows) { try { if ((bool)item.Cells[0].Value) { POLineModel line = (POLineModel)item.DataBoundItem; lines.Add(line); } } catch { //MessageBox.Show(ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } if (lines.Count != 0) { _view.linesSelected = lines; _view.CloseMe(); } } }
private void Adjust(object sender, EventArgs e) { MetroGrid grid = sender as MetroGrid; List <POLineModel> temps = _repository.GetPOLineByPOID(_view.poLines.FirstOrDefault().PoHeaderId); if (grid.SelectedRows.Count > 0) { List <POLineModel> lines = new List <POLineModel>(); foreach (DataGridViewRow item in grid.Rows) { try { POLineModel line = (POLineModel)item.DataBoundItem; POLineModel temp = temps.Where(x => x.PoLineId == line.PoLineId).FirstOrDefault(); if (line.Quantity != temp.Quantity) { lines.Add(line); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } if (lines.Count != 0) { SaveLinesAdjust(lines); } } }
public void Delete(POLineModel model) { string sql = @"DELETE FROM po_lines_all WHERE po_line_id = @po_line_id"; object[] parms = { "@po_line_id", model.PoLineId }; db.Update(sql, parms); }
public int InsertPOLine(POLineModel model) { model.CreationDate = DateTime.Now; model.LastUpdateDate = DateTime.Now; return(factory.POLineDao.Insert(model)); }
private object[] Take(POLineModel model) { return(new object[] { "@po_line_id", model.PoLineId, "@po_header_id", model.PoHeaderId, "@po_line_num", model.PoLineNum, "@status", model.Status, "@line_type", model.LineType, "@last_update_date", model.LastUpdateDate, "@last_updated_by", model.LastUpdatedBy, "@creation_date", model.CreationDate, "@created_by", model.CreatedBy, "@item_id", model.ItemId, "@item_description", model.ItemDescription, "@uom", model.Uom, "@quantity", model.Quantity, "@qunitity_completed", model.QunitityCompleted, "@base_unit_price", model.BaseUnitPrice, "@tax_able_flag", model.TaxAbleFlag, "@tax_code", model.TaxCode, "@tax_rate", model.TaxRate, "@tax_amount", model.TaxAmount, "@unit_price", model.UnitPrice, "@extended_amount", model.ExtendedAmount, "@ref_project_id", model.RefProjectId, "@ref_project_num", model.RefProjectNum, "@bom_line_id", model.BomLineId, "@bom_release", model.BomRelease, "@proj_cost_id", model.ProjCostId, "@cost_code", model.CostCode, "@balloon_no", model.BalloonNo, "@bom", model.BOM, "@item_code", model.ItemCode, "@spec_model", model.Spec, "@brand_materail", model.BrandMaterail, //"@rev", model.Rev, "@due_date", model.DueDate, "@ecn_no", model.ECN, "@csr_no", model.CSR, "@lead_time", model.LeadTime, "@load_bom_date", model.LoadBomDate, "@suplier", model.Suplier, "@job_making_flag", model.JobMakingFlag ? "Y" : "N", "@cancel_flag", model.CancelFlag ? "Y" : "N", "@encumbrance_flag", (model.EncumbranceFlag) ? "Y" : "N", "@dupplicate_line_flag", (model.DupplicateFlag) ? "Y" : "N", "@encumbrance_amount", model.EncumbranceAmount, "@error_message", model.LineErrorMessage, "@currency_code", model.CurrencyCode, "@currency_rate", model.CurrencyRate }); }
public void Update(POLineModel model) { string sql = @"UPDATE po_lines_all SET po_header_id = @po_header_id ,po_line_num = @po_line_num ,status = @status ,line_type = @line_type ,last_update_date = @last_update_date ,last_updated_by = @last_updated_by ,item_id = @item_id ,item_description = @item_description ,uom = @uom ,quantity = @quantity ,qunitity_completed = @qunitity_completed ,base_unit_price = @base_unit_price ,tax_able_flag = @tax_able_flag ,tax_code = @tax_code ,tax_rate = @tax_rate ,tax_amount = @tax_amount ,unit_price = @unit_price ,extended_amount = @extended_amount ,ref_project_id = @ref_project_id ,ref_project_num = @ref_project_num ,bom_line_id = @bom_line_id ,bom_release = @bom_release ,proj_cost_id = @proj_cost_id ,cost_code = @cost_code ,balloon_no = @balloon_no ,bom = @bom ,item_code = @item_code ,spec_model = @spec_model ,brand_materail = @brand_materail ,due_date = @due_date ,ecn_no = @ecn_no ,csr_no = @csr_no ,lead_time = @lead_time ,load_bom_date = @load_bom_date ,suplier = @suplier ,job_making_flag = @job_making_flag ,cancel_flag = @cancel_flag ,encumbrance_flag = @encumbrance_flag ,encumbrance_amount = @encumbrance_amount ,dupplicate_line_flag = @dupplicate_line_flag ,error_message = @error_message ,currency_code = @currency_code ,currency_rate = @currency_rate WHERE po_line_id = @po_line_id"; db.Update(sql, Take(model)); }
private void ConvertPO_Click(object sender, EventArgs e) { //_view.RefreshLinesGird(); bool jobProcess = false; int vendorId = 0; string poTypeCode = string.Empty; if (_view.linesSelected.Count == 0) { return; } var reqLines = _view.linesSelected; //Validation multiple Vendors var resVendors = reqLines.GroupBy(x => x.VendorId) .Select(group => new { Vendor = group.Key, lines = group.ToList() }) .ToList(); if (resVendors.Count > 1) { MessageBox.Show("Lines seleted more than one Vendors, cannot convert PO to one by one.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { vendorId = resVendors.FirstOrDefault().Vendor; } //Validation multiple Line Type var resTypes = reqLines.GroupBy(x => x.LineType) .Select(group => new { LineType = group.Key, lines = group.ToList() }) .ToList(); if (resTypes.Count > 1) { MessageBox.Show("Lines seleted more than one Type, cannot convert PO to one by one.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { //Set PO Type Code. poTypeCode = resTypes.FirstOrDefault().LineType; var costs = _repoProj.GetCostGropAll(); var str = (from c in _view.linesSelected select new { costCode = c.CostCode }).ToArray(); var query = costs.Where(x => str.Any(a => a.costCode == x.CostCode)).ToList() .GroupBy(p => p.MakingFlag) .Select(group => new { makings = group.Key, glines = group.ToList() }) .ToList(); if (query.Count > 1) { MessageBox.Show("Lines seleted more than one Type, cannot convert PO to one by one.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { //Set PO Job Process Flag. jobProcess = query.ToList().FirstOrDefault().makings; } //var jobProcessCosts = costs.Where(x => costs) } var resUnConfirm = reqLines.Where(x => !x.FinalConfirmFlag).ToList(); if (resUnConfirm.Count > 0) { MessageBox.Show("Some lines seleted is not Confirm price.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } POHeaderModel head = new POHeaderModel(); head.ProjectId = _view.projectParam.Id; head.ProjectNum = _view.projectParam.ProjectNum; head.JobFlag = jobProcess; head.TypeLookupCode = poTypeCode; head.VendorId = vendorId; head.PODate = DateTime.Now; head.Status = "OPEN"; head.StatusCode = "OPEN"; head.BuyerId = _view.EpiSession.User.Id; head.BuyerName = _view.EpiSession.User.UserName; string typeLookup = string.Empty; if (head.TypeLookupCode == "STANDARD") { typeLookup = "PURCHASE_PO"; } else if (head.TypeLookupCode == "MAKING") { if (head.JobFlag) { typeLookup = "PURCHASE_PD"; } else { typeLookup = "PURCHASE_PO"; } } //Combind Vendor Detail. head = CombindVendor(head); head.SubTotal = _view.linesSelected.Sum(x => x.ExtendedAmount); head.PoNum = _repoPO.GetDocNoByType(typeLookup); head.PoHeaderId = _repoPO.InsertPO(head); //Validate to Add Line if (head.PoHeaderId != 0) { try { if (_view.linesSelected != null) { //List<POLineModel> list = _view.poLine; foreach (RequisitionLineModel item in _view.linesSelected) { POLineModel pol = new POLineModel(); pol.PoHeaderId = head.PoHeaderId; pol.LastUpdatedBy = _view.EpiSession.User.Id; pol.CreatedBy = _view.EpiSession.User.Id; pol.RefProjectId = _view.projectParam.Id; pol.RefProjectNum = _view.projectParam.ProjectNum; pol.LastUpdateDate = DateTime.Now; pol.CreationDate = DateTime.Now; pol.Status = "OPEN"; pol.BalloonNo = item.BalloonNo; pol.ItemCode = item.ItemCode; pol.Quantity = item.Quantity; pol.ItemDescription = item.ItemDescription; pol.Spec = item.SpecModel; pol.BrandMaterail = item.BrandMaterail; pol.CostCode = item.CostCode; pol.BOM = item.BomNo; pol.Suplier = item.SuplierSymbol; pol.UnitPrice = item.FinalUnitPrice; pol.DueDate = item.DueDate; pol.ECN = item.EcnNo; pol.CSR = item.CsrNo; pol.Uom = item.Uom; pol.LeadTime = item.LeadTime; pol.LoadBomDate = item.LoadBomDate; int lineId = _repoPO.InsertPOLine(pol); if (lineId != 0) { item.PurchasedFlag = true; item.PurchasedQuantity = item.Quantity; item.PoLineId = lineId; item.PoHeaderId = head.PoHeaderId; _repository.UpdatePRLine(item); } } //Update Purchased flag in Requisition Header var grpHeads = _view.linesSelected.GroupBy(item => item.RequisitionHeaderId) .Select(group => new { reqHeaderId = group.Key, ReqLines = group.ToList() }) .ToList(); foreach (var req in grpHeads) { _repository.UpdatePurchasedFlag(req.reqHeaderId); } } } catch (Exception ex) { MessageBox.Show("PO Lines is Error! " + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Filter(null, null); MessageBox.Show(string.Format("Convert to PO Number : {0} complete.", head.PoNum), "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); POEntryForm POfrm = new POEntryForm(head); POfrm.Show(); } }
public int Insert(POLineModel model) { string sql = @"INSERT INTO po_lines_all (po_header_id ,po_line_num ,status ,line_type ,last_update_date ,last_updated_by ,creation_date ,created_by ,item_id ,item_description ,uom ,quantity ,qunitity_completed ,base_unit_price ,tax_able_flag ,tax_code ,tax_rate ,tax_amount ,unit_price ,extended_amount ,ref_project_id ,ref_project_num ,bom_line_id ,bom_release ,proj_cost_id ,cost_code ,balloon_no ,bom ,item_code ,spec_model ,brand_materail ,due_date ,ecn_no ,csr_no ,lead_time ,load_bom_date ,suplier ,job_making_flag ,cancel_flag ,encumbrance_flag ,encumbrance_amount ,dupplicate_line_flag ,error_message ,currency_code ,currency_rate) VALUES (@po_header_id ,@po_line_num ,@status ,@line_type ,@last_update_date ,@last_updated_by ,@creation_date ,@created_by ,@item_id ,@item_description ,@uom ,@quantity ,@qunitity_completed ,@base_unit_price ,@tax_able_flag ,@tax_code ,@tax_rate ,@tax_amount ,@unit_price ,@extended_amount ,@ref_project_id ,@ref_project_num ,@bom_line_id ,@bom_release ,@proj_cost_id ,@cost_code ,@balloon_no ,@bom ,@item_code ,@spec_model ,@brand_materail ,@due_date ,@ecn_no ,@csr_no ,@lead_time ,@load_bom_date ,@suplier ,@job_making_flag ,@cancel_flag ,@encumbrance_flag ,@encumbrance_amount ,@dupplicate_line_flag ,@error_message ,@currency_code ,@currency_rate)"; return(db.Insert(sql, Take(model))); }
public void DeletePOLine(POLineModel model) { factory.POLineDao.Delete(model); }
public void UpdatePOLine(POLineModel model) { model.LastUpdateDate = DateTime.Now; factory.POLineDao.Update(model); }