private void SaveCAPDetail() { foreach (DataGridViewRow listItem in dgvDetailList.Rows) { if (DAL.Common.Utility.IsGUID(listItem.Cells[0].Value.ToString().Trim()) && DAL.Common.Utility.IsGUID(listItem.Cells[12].Value.ToString().Trim())) { System.Guid detailId = new Guid(listItem.Cells[0].Value.ToString().Trim()); InvtBatchCAP_Details oDetail = InvtBatchCAP_Details.Load(detailId); if (oDetail == null) { oDetail = new InvtBatchCAP_Details(); oDetail.HeaderId = this.CAPHeaderId; oDetail.TxNumber = txtTxNumber.Text; oDetail.TxType = txtTxType.Text; oDetail.LineNumber = Convert.ToInt32(listItem.Cells[1].Value.ToString().Length == 0 ? "1" : listItem.Cells[1].Value.ToString()); } oDetail.ProductId = new Guid(listItem.Cells[12].Value.ToString().Trim()); oDetail.Qty = Convert.ToDecimal(listItem.Cells[8].Value.ToString().Length == 0 ? "0" : listItem.Cells[8].Value.ToString()); oDetail.UnitAmount = Convert.ToDecimal(listItem.Cells[10].Value.ToString().Length == 0 ? "0" : listItem.Cells[10].Value.ToString()); oDetail.UnitAmountInForeignCurrency = Convert.ToDecimal(listItem.Cells[9].Value.ToString().Length == 0 ? "0" : listItem.Cells[9].Value.ToString()); if (listItem.Cells[2].Value.ToString().Trim().ToUpper() == "REMOVED" && detailId != System.Guid.Empty) { oDetail.Delete(); } else { oDetail.Save(); } } } }
private void DeleteDetails(string sql) { InvtBatchCAP_DetailsCollection oDetailList = InvtBatchCAP_Details.LoadCollection(sql); foreach (InvtBatchCAP_Details oDetail in oDetailList) { oDetail.Delete(); } }
private decimal GetTotalRequiredQty() { decimal totalQty = 0; string sql = "HeaderId = '" + this.CAPHeaderId.ToString() + "'"; InvtBatchCAP_DetailsCollection oDetails = InvtBatchCAP_Details.LoadCollection(sql); foreach (InvtBatchCAP_Details oDetail in oDetails) { totalQty += oDetail.Qty; } return(totalQty); }
private decimal GetTotalAmount() { decimal totalAmt = 0; string sql = "HeaderId = '" + this.CAPHeaderId.ToString() + "'"; InvtBatchCAP_DetailsCollection oDetails = InvtBatchCAP_Details.LoadCollection(sql); foreach (InvtBatchCAP_Details oDetail in oDetails) { decimal xchgRate = Convert.ToDecimal(DAL.Common.Utility.IsNumeric(txtExchgRate.Text) ? txtExchgRate.Text.Trim() : "1"); totalAmt += oDetail.UnitAmount * oDetail.Qty; } return(totalAmt); }