public string SaveDetails(List<REceiptTypes.ReceiptDetailsDataType> ReceiptList,string RcptNo, MySqlConnection _ActCon) { string respond=""; try { foreach (REceiptTypes.ReceiptDetailsDataType OneItem in ReceiptList) { REceiptTypes.ReceiptDetailsDataType _OneItem = new REceiptTypes.ReceiptDetailsDataType(); _OneItem = OneItem; _OneItem.RcptNo = RcptNo; if (!ExistReceiptDetails(OneItem.ItemNo, RcptNo, _ActCon)) { respond = SaveReceiptDetails(_OneItem, _ActCon); } if (respond != "True") return respond; } return respond; } catch (Exception ex) { return ex.Message; } }
public string GetReceiptList(string RcptNumber, out List<REceiptTypes.ReceiptDetailsDataType> _RcptDetailList) { _RcptDetailList = new List<REceiptTypes.ReceiptDetailsDataType>(); string sql1 = "Select ItemNo,RcptNo from tblreceiptdetails Where RcptNo=@RcptNo"; MySqlCommand oSqlCommand = new MySqlCommand(); oSqlCommand.Parameters.AddWithValue("@RcptNo", RcptNumber); DataTable tb = Mycommon.GetDataTableAccount(sql1, oSqlCommand, "Get Exist data ReceiptDetails"); string Respond = ""; if (tb != null) { foreach (DataRow r in tb.Rows) { REceiptTypes.ReceiptDetailsDataType _OneItem = new REceiptTypes.ReceiptDetailsDataType(); int i=int.Parse(r["ItemNo"].ToString()); Respond = GetExistReceiptDetails(i, RcptNumber, out _OneItem); if (Respond =="True") _RcptDetailList.Add(_OneItem); } } return Respond; }
public string GetExistReceiptDetails(int ItemNo, string RcptNo, out REceiptTypes.ReceiptDetailsDataType _ExistData) { _ExistData = new REceiptTypes.ReceiptDetailsDataType(); MySqlCommand oSqlCommand = new MySqlCommand(); string sqlQuery = "Select " + "ItemNo," + "RcptNo," + "AccID," + "Description," + "Cr," + "FCr," + "RcptTrRef," + "Vat," + "JobNo,Exrate" + " from tblreceiptdetails" + " Where 1=1 " + " and ItemNo=@ItemNo" + " and RcptNo=@RcptNo"; oSqlCommand.Parameters.AddWithValue("@ItemNo", ItemNo); oSqlCommand.Parameters.AddWithValue("@RcptNo", RcptNo); DataRow r = Mycommon.GetDataRowAccount(sqlQuery, oSqlCommand, "Get Exist data ReceiptDetails"); if (r != null) { try { bool resp = false; int inItemNo = 0; resp = int.TryParse(r["ItemNo"].ToString(), out inItemNo); _ExistData.ItemNo = inItemNo; _ExistData.RcptNo = r["RcptNo"].ToString(); _ExistData.AccID = r["AccID"].ToString(); _ExistData.Description = r["Description"].ToString(); decimal deCr = 0; resp = decimal.TryParse(r["Cr"].ToString(), out deCr); _ExistData.Cr = deCr; decimal deFCr = 0; resp = decimal.TryParse(r["FCr"].ToString(), out deFCr); _ExistData.FCr = deFCr; _ExistData.RcptTrRef = r["RcptTrRef"].ToString(); decimal deVat = 0; resp = decimal.TryParse(r["Vat"].ToString(), out deVat); _ExistData.Vat = deVat; _ExistData.JobNo = r["JobNo"].ToString(); decimal deExrate = 0; resp = decimal.TryParse(r["Exrate"].ToString(), out deExrate); _ExistData.Exrate = deExrate; return "True"; } catch (Exception ex) { return ex.Message; } } else return "data not found "; }
private string SetDetailDataToClass(out List<REceiptTypes.ReceiptDetailsDataType> _SaveDetailList) { // MyPay = new Payment(Program.AccountStatic.LoggingAsLocal); _SaveDetailList = new List<REceiptTypes.ReceiptDetailsDataType>(); try { foreach (DataGridViewRow OneRow in dgvAccList.Rows) { REceiptTypes.ReceiptDetailsDataType _OneItem = new REceiptTypes.ReceiptDetailsDataType(); _OneItem.AccID = OneRow.Cells["dgvAccList_AccountID"].Value.ToString(); _OneItem.Description = OneRow.Cells["dgvAccList_Memo"].Value.ToString(); bool resp = false; decimal Cr = 0, FCr = 0, Vat = 0, Lexrare=0; resp = decimal.TryParse(OneRow.Cells["dgvAccList_Amount"].Value.ToString(), out Cr); resp = decimal.TryParse(OneRow.Cells["dgvAccList_Fcur"].Value.ToString(), out FCr); resp = decimal.TryParse(OneRow.Cells["dgvAccList_Vat"].Value.ToString(), out Vat); resp = decimal.TryParse(OneRow.Cells["dgvAccList__ExcRate"].Value.ToString(), out Lexrare); _OneItem.Cr = Cr; _OneItem.FCr = FCr; _OneItem.ItemNo = int.Parse(OneRow.Cells["dgvAccList_Ref"].Value.ToString()); _OneItem.RcptNo = txtRcptNumber.Text; _OneItem.Vat = Vat; _OneItem.JobNo = OneRow.Cells["dgvAccList_Job"].Value.ToString(); _OneItem.Exrate = Lexrare; _SaveDetailList.Add(_OneItem); } return "True"; } catch (Exception ex) { return ex.Message; } }