public ReceiveArticleDialog(StoreInPlanDetailModel model, SessionInfo _session, int LineReceive, decimal WeightReceive) { InitializeComponent(); this._repo = new StoreInPlanRepo(); this._repoWhse = new WharehouseRepo(); this.ArticleList = new List<StoreInPlanDetailModel>(); this.lineNum = model; this.numofline = LineReceive; this.WeightRcv = WeightReceive; this.DataFlag = false; epiSession = _session; }
public void SaveArticle(StoreInPlanDetailModel model, SessionInfo _session) { ///TODO : not yet fix GETDATE() string sql = ""; sql += string.Format(@"IF NOT EXISTS ( SELECT * FROM ucc_ic_StoreInPlanDtl (NOLOCK) WHERE LineId = {17} ) BEGIN INSERT INTO ucc_ic_StoreInPlanDtl (Company ,Plant ,StoreInPlanId ,PONumber ,PONum ,POLine ,SpecName ,Thick ,ArticleNo ,Quantity ,Weight ,Place ,Note ,CreationDate ,LastUpdateDate ,CreatedBy ,UpdatedBy ,Width ,Length ,SeqId ,StoreInFlag ,SpecCode ------------ ,CommodityCode ,CoatingCode ,PackingNo ,Category ,SContract) VALUES (N'{0}' --<Company, nvarchar(15),> ,N'{1}' --<Plant, nvarchar(15),> ,{2} --<StoreInPlanId, int,> ,N'{13}' --<PONumber, nvarchar(20),> ,{3} --<PONum, int,> ,{4} --<POLine, int,> ,N'{5}' --<SpecName, nvarchar(50),> ,{6} --<Thick, decimal(15,2),> ,N'{7}' --<ArticleNo, nvarchar(50),> ,{8} --<Quantity, decimal(15,2),> ,{9} --<Weight, decimal(15,2),> ,N'{10}' --<Place, nvarchar(30),> ,N'{11}' --<Note, nvarchar(max),> ,GETDATE() --<CreationDate, datetime,> ,GETDATE() --<LastUpdateDate, datetime,> ,N'{12}' --<CreatedBy, varchar(45),> ,N'{12}' --<UpdatedBy, varchar(45),>) ,{14} --<Width, decimal(15,2),> ,{15} --<Length, decimal(15,2),> ,{16} ,{18} ,N'{19}' ------------ ,N'{20}' ,N'{21}' ,N'{22}' ,N'{23}' ,N'{24}' ) END ELSE BEGIN UPDATE ucc_ic_StoreInPlanDtl SET ArticleNo = N'{7}' --<ArticleNo, nvarchar(50),> ,Quantity = {8} --<Quantity, decimal(15,2),> ,Weight = {9} --<Weight, decimal(15,2),> ,Place = N'{10}' --<Place, nvarchar(30),> ,LastUpdateDate = GETDATE() --<LastUpdateDate, datetime,> ,UpdatedBy = N'{12}' --<UpdatedBy, varchar(45),> WHERE LineId = {17} END " + Environment.NewLine , _session.CompanyID , _session.PlantID , model.StoreInPlanId , model.PONum , model.POLine , model.SpecCode , model.Thick , model.ArticleNo , model.Quantity , model.Weight , model.Place , model.Note , _session.UserID , model.PONumber , model.Width , model.Length , model.SeqId , model.LineID , 0 , model.SpecCode , model.CommodityCode , model.CoatingCode , model.PackingNumber , model.Category , model.SaleContract); Repository.Instance.ExecuteWithTransaction(sql, "Store In Plan Detail"); }
private void butArticleDetail_Click(object sender, EventArgs e) { bool ErrorFlag = false; if (HeadContent.InsertState) { MessageBox.Show("Please save store in plan no : " + this.txtStoreInPlanNum.Text.ToString() + " before to adding article line.", "Please save.", MessageBoxButtons.OK, MessageBoxIcon.Hand); ErrorFlag = true; } else { if (string.IsNullOrEmpty(txtPoNumber.Text)) { errorProvider1.SetError(txtPoNumber, "Please fill the required field."); ErrorFlag = true; } if (string.IsNullOrEmpty(txtPoLine.Text)) { errorProvider1.SetError(txtPoLine, "Please fill the required field."); ErrorFlag = true; } if (Convert.ToInt32(string.IsNullOrEmpty(txtNumberOfArticle.Text.Trim()) ? "0" : txtPoLine.Text.Trim()) <= 0) { errorProvider1.SetError(txtNumberOfArticle, "Please fill the required field."); ErrorFlag = true; } if (Convert.ToDecimal(string.IsNullOrEmpty(txtReceiptWeight.Text.Trim()) ? "0" : txtReceiptWeight.Text.Trim()) <= 0) { errorProvider1.SetError(txtReceiptWeight, "Please fill the required field."); ErrorFlag = true; } } if (!ErrorFlag) { StoreInPlanDetailModel paramModel = new StoreInPlanDetailModel(); //decimal ReceiptWeight = Convert.ToDecimal(string.IsNullOrEmpty(txtReceiptWeight.Text.Trim()) ? "0" : txtReceiptWeight.Text.Trim()); paramModel = _repo.GetPoLineDetail(txtPoNumber.Text.Trim(), Convert.ToInt32(txtPoLine.Text.Trim())); if (paramModel == null) { MessageBox.Show("This PO line dose not exist.", "Invalid value.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } paramModel.PONumber = txtPoNumber.Text.Trim(); paramModel.StoreInPlanId = HeadContent.StoreInPlanId; paramModel.PONum = POTrans.PONum; paramModel.PackingNumber = HeadContent.InvoiceNum; paramModel.POLine = Convert.ToInt32(txtPoLine.Text.Trim()); paramModel.WeightBalnce = _repo.GetReceivedWeight(paramModel.PONum, paramModel.POLine); paramModel.POAllowance = _repo.GetMCSSAllowance(paramModel.PartNum); int NumberOfArt = Convert.ToInt32(string.IsNullOrEmpty(txtNumberOfArticle.Text.Trim()) ? "0" : txtNumberOfArticle.Text.Trim()); decimal decAllowance = (POTrans.BalanceWeight * paramModel.POAllowance) / 100; if (Convert.ToDecimal(txtReceiptWeight.Text) <= (POTrans.BalanceWeight + decAllowance)) { ReceiveArticleDialog frm = new ReceiveArticleDialog(paramModel, epiSession, NumberOfArt, Convert.ToDecimal(txtReceiptWeight.Text)); frm.ShowDialog(); SetHeaderContent(HeadContent); ClearPOLineTrans(); } else { MessageBox.Show("Receipt weight must be less than or equal Remaining weight.", "Invalid value.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } }
private void tlbSave_Click(object sender, EventArgs e) { tlbInactive_Click(sender, e); if (!DataFlag) { MessageBox.Show("Plaes validate data before save.", "Invalid data.", MessageBoxButtons.OK, MessageBoxIcon.Error); } else if (DataFlag) { for (int i = 0; (this.dataGridView1.Rows.Count) > i; i++) { StoreInPlanDetailModel param = new StoreInPlanDetailModel(); param.SeqId = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value.ToString().Trim()); param.StoreInPlanId = lineNum.StoreInPlanId; param.LineID = 0; param.PONumber = lineNum.PONumber; param.PONum = lineNum.PONum; param.POLine = lineNum.POLine; param.SpecCode = lineNum.SpecCode; param.Thick = lineNum.Thick; param.Width = lineNum.Width; param.Length = lineNum.Length; param.ArticleNo = dataGridView1.Rows[i].Cells[6].Value.ToString().Trim(); param.Quantity = Convert.ToDecimal(dataGridView1.Rows[i].Cells[7].Value.ToString().Trim()); param.Weight = Convert.ToDecimal(dataGridView1.Rows[i].Cells[8].Value.ToString().Trim()); param.Place = dataGridView1.Rows[i].Cells[9].Value.ToString().Trim(); param.PackingNumber = dataGridView1.Rows[i].Cells[10].Value.ToString().Trim(); param.Note = dataGridView1.Rows[i].Cells[11].Value.ToString().Trim(); param.EndUserID = dataGridView1.Rows[i].Cells[12].Value.ToString().Trim(); _repo.SaveArticle(param, epiSession); } this.Close(); } }
private void UpdateArticleLine() { if (HeadContent.ImportFlag == 2) { for (int i = 0; (this.dataGridView2.Rows.Count) > i; i++) { if (!string.IsNullOrEmpty(dataGridView2.Rows[i].Cells["id1"].Value.GetString())) { StoreInPlanDetailModel param = new StoreInPlanDetailModel(); param.SeqId = Convert.ToInt32(dataGridView2.Rows[i].Cells["lineid"].Value); param.StoreInPlanId = HeadContent.StoreInPlanId; param.LineID = Convert.ToInt32(dataGridView2.Rows[i].Cells["id1"].Value); param.ArticleNo = dataGridView2.Rows[i].Cells["article"].Value.GetString(); param.CommodityCode = dataGridView2.Rows[i].Cells["commodity1"].Value.GetString(); param.SpecCode = dataGridView2.Rows[i].Cells["spec1"].Value.GetString(); param.CoatingCode = dataGridView2.Rows[i].Cells["Coating"].Value.GetString(); param.Thick = Convert.ToDecimal(dataGridView2.Rows[i].Cells["thick"].Value); param.Width = Convert.ToDecimal(dataGridView2.Rows[i].Cells["width"].Value); param.Length = Convert.ToDecimal(dataGridView2.Rows[i].Cells["length"].Value); param.Quantity = Convert.ToDecimal(dataGridView2.Rows[i].Cells["quantity2"].Value); param.Weight = Convert.ToDecimal(dataGridView2.Rows[i].Cells["weight2"].Value); param.Place = dataGridView2.Rows[i].Cells["place1"].Value.GetString(); param.PackingNumber = dataGridView2.Rows[i].Cells["packingno1"].Value.GetString(); param.Category = dataGridView2.Rows[i].Cells["category"].Value.GetString(); param.SaleContract = dataGridView2.Rows[i].Cells["mksale"].Value.GetString(); param.Note = dataGridView2.Rows[i].Cells["note1"].Value.GetString(); _repo.SaveArticle(param, epiSession); } } } else { for (int i = 0; (this.dataGridView1.Rows.Count) > i; i++) { if (dataGridView1.Columns[10].Name == "edit" && (bool)dataGridView1[10, i].EditedFormattedValue) { StoreInPlanDetailModel param = new StoreInPlanDetailModel(); param.SeqId = Convert.ToInt32(dataGridView1.Rows[i].Cells["SeqId"].Value); param.StoreInPlanId = HeadContent.StoreInPlanId; param.LineID = Convert.ToInt32(dataGridView1.Rows[i].Cells["id"].Value); param.ArticleNo = dataGridView1.Rows[i].Cells["articleno"].Value.GetString(); param.Quantity = Convert.ToDecimal(dataGridView1.Rows[i].Cells["quantity1"].Value); param.Weight = Convert.ToDecimal(dataGridView1.Rows[i].Cells["weight1"].Value); param.Place = dataGridView1.Rows[i].Cells["place"].Value.GetString(); DataGridViewRow row = dataGridView1.Rows .Cast<DataGridViewRow>() .Where(r => r.Cells["articleno"].Value.ToString().Equals(dataGridView1.Rows[i].Cells["articleno"].Value.ToString())).First(); int rowIndex = row.Index; if (rowIndex != i) { dataGridView1.CurrentCell = dataGridView1[3, i]; MessageBox.Show("Article No is duplicate.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { _repo.SaveArticle(param, epiSession); } } } } }