private string SetDetailDataToClass(out List<AccountTypes.Payment_GeneralDetailsDataType> _SaveDetailList) { MyPay = new Payment(Program.AccountStatic.LoggingAsLocal); _SaveDetailList = new List<AccountTypes.Payment_GeneralDetailsDataType>(); try { foreach (DataGridViewRow OneRow in dgvAccList.Rows) { AccountTypes.Payment_GeneralDetailsDataType _OneItem = new AccountTypes.Payment_GeneralDetailsDataType(); _OneItem.AccID = OneRow.Cells["dgvAccList_AccountID"].Value.ToString(); _OneItem.Description = OneRow.Cells["dgvAccList_Memo"].Value.ToString(); bool resp = false; decimal Dr = 0, FDr = 0, Vat = 0, Lexrare = 0; resp = decimal.TryParse(OneRow.Cells["dgvAccList_Amount"].Value.ToString(), out Dr); resp = decimal.TryParse(OneRow.Cells["dgvAccList_Fcur"].Value.ToString(), out FDr); resp = decimal.TryParse(OneRow.Cells["dgvAccList_Vat"].Value.ToString(), out Vat); resp = decimal.TryParse(OneRow.Cells["dgvAccList__ExcRate"].Value.ToString(), out Lexrare); _OneItem.Dr = Dr; _OneItem.Fdr = FDr; _OneItem.ItemNo = int.Parse(OneRow.Cells["dgvAccList_Ref"].Value.ToString()); _OneItem.PvnNo = txtPVNno.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; } }
public string SavePayment_General(AccountTypes.Payment_GeneralDataType _SaveData,out string PVN) { MySql.Data.MySqlClient.MySqlTransaction Mytrans; MySqlConnection CurCon = new MySqlConnection(); CurCon = Mycommon.AccountConnection; if (CurCon.State == ConnectionState.Closed) CurCon.Open(); PVN = GetNewTMPPayID(_SaveData.CompanyID, _SaveData.AccPeriod); Mytrans = Mycommon.AccountConnection.BeginTransaction(); MySqlCommand oSqlCommand = new MySqlCommand(); string sqlQuery = "Insert Into tblpayment (" + "PaymentID," + "PaymentMethod," + "Description," + "AccountID," + "CurRate," + "Cr," + "FCr," + "PayStatus," + "TrRef," + "TrUser," + "TrDate," + "TrTime," + "ChequeNumber,AccPeriod,CompanyID,PayToCatID,PayToName,PayActualDate,IsAdvancePayment)" + " Values (" + "@PaymentID," + "@PaymentMethod," + "@Description," + "@AccountID," + "@CurRate," + "@Cr," + "@FCr," + "@PayStatus," + "@TrRef," + "@TrUser," + "curdate()," + "curtime()," + "@ChequeNumber,@AccPeriod,@CompanyID,@PayToCatID,@PayToName,@PayActualDate,IsAdvancePayment)"; try { oSqlCommand.Parameters.AddWithValue("@PaymentID", PVN); oSqlCommand.Parameters.AddWithValue("@PaymentMethod", _SaveData.PaymentMethod); oSqlCommand.Parameters.AddWithValue("@Description", _SaveData.Description); oSqlCommand.Parameters.AddWithValue("@AccountID", _SaveData.AccountID); oSqlCommand.Parameters.AddWithValue("@CurRate", _SaveData.CurRate); oSqlCommand.Parameters.AddWithValue("@Cr", _SaveData.Cr); oSqlCommand.Parameters.AddWithValue("@FCr", _SaveData.FCr); oSqlCommand.Parameters.AddWithValue("@PayStatus", _SaveData.PayStatus); oSqlCommand.Parameters.AddWithValue("@TrRef", _SaveData.TrRef); oSqlCommand.Parameters.AddWithValue("@TrUser", _SaveData.TrUser); oSqlCommand.Parameters.AddWithValue("@ChequeNumber", _SaveData.ChequeNumber); oSqlCommand.Parameters.AddWithValue("@AccPeriod", _SaveData.AccPeriod); oSqlCommand.Parameters.AddWithValue("@CompanyID", _SaveData.CompanyID); oSqlCommand.Parameters.AddWithValue("@PayToCatID", _SaveData.PayToCatID); oSqlCommand.Parameters.AddWithValue("@PayToName", _SaveData.PayToName); oSqlCommand.Parameters.AddWithValue("@PayActualDate", _SaveData.PayActualDate); oSqlCommand.Parameters.AddWithValue("@IsAdvancePayment", _SaveData.IsAdvancePayment); string respond = Mycommon.ExicuteAnyCommandAccountWithTrans(sqlQuery, oSqlCommand,CurCon, "Save Payment_General"); if (respond == "True") { foreach (AccountTypes.Payment_GeneralDetailsDataType OneItem in _SaveData.Details) { bool Exist = ExistPayment_GeneralDetails(OneItem.ItemNo, PVN, CurCon, Mytrans); if (!Exist) { AccountTypes.Payment_GeneralDetailsDataType OneItemSecond = new AccountTypes.Payment_GeneralDetailsDataType(); OneItemSecond = OneItem; OneItemSecond.PvnNo = PVN; respond = SavePayment_GeneralDetails(OneItemSecond, CurCon, Mytrans); } if (respond != "True") { Mytrans.Rollback(); return respond; } } if (respond == "True") { try { Mytrans.Commit(); return respond; } catch (Exception ex) { Mytrans.Rollback (); return ex.Message ; } } else { Mytrans.Rollback (); CurCon.Close(); CurCon.Dispose(); return respond; } } else { Mytrans.Rollback(); return respond; } } catch (Exception ex) { return ex.Message; } }
public string GetExistPayment_GeneralDetails(int ItemNo, string PvnNo, out AccountTypes.Payment_GeneralDetailsDataType _ExistData) { _ExistData = new AccountTypes.Payment_GeneralDetailsDataType(); MySqlCommand oSqlCommand = new MySqlCommand(); string sqlQuery = "Select " + "ItemNo," + "PvnNo," + "AccID," + "Description," + "Dr," + "Fdr," + "PayTrRef," + "Vat,JobNo,Exrate" + " from tblpaymetdetails" + " Where 1=1 " + " and ItemNo=@ItemNo" + " and PvnNo=@PvnNo"; oSqlCommand.Parameters.AddWithValue("@ItemNo", ItemNo); oSqlCommand.Parameters.AddWithValue("@PvnNo", PvnNo); DataRow r = Mycommon.GetDataRowAccount(sqlQuery, oSqlCommand, "Get Exist data Payment_GeneralDetails"); if (r != null) { try { bool resp = false; int inItemNo = 0; resp = int.TryParse(r["ItemNo"].ToString(), out inItemNo); _ExistData.ItemNo = inItemNo; _ExistData.PvnNo = r["PvnNo"].ToString(); _ExistData.AccID = r["AccID"].ToString(); _ExistData.Description = r["Description"].ToString(); decimal deDr = 0; resp = decimal.TryParse(r["Dr"].ToString(), out deDr); _ExistData.Dr = deDr; decimal deFdr = 0; resp = decimal.TryParse(r["Fdr"].ToString(), out deFdr); _ExistData.Fdr = deFdr; _ExistData.PayTrRef = r["PayTrRef"].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 "; }
public string GetPaymentDetailList(string PVN, out List<AccountTypes.Payment_GeneralDetailsDataType> _PayList) { MySqlCommand oSqlCommand = new MySqlCommand(); _PayList=new List<AccountTypes.Payment_GeneralDetailsDataType> (); string sql1 = "select PvnNo, ItemNo from tblpaymetdetails where PvnNo=@PvnNo"; oSqlCommand.Parameters.AddWithValue("@PvnNo", PVN); string respond = ""; try { DataTable tb = Mycommon.GetDataTableAccount(sql1, oSqlCommand, "Get Payment list"); if (tb != null) { foreach (DataRow r in tb.Rows) { AccountTypes.Payment_GeneralDetailsDataType _Onedata = new AccountTypes.Payment_GeneralDetailsDataType(); int itemNo = 0; bool resp = int.TryParse(r["ItemNo"].ToString(), out itemNo); respond = GetExistPayment_GeneralDetails(itemNo, PVN, out _Onedata); if (respond == "True") _PayList.Add(_Onedata); else return respond; } return "True"; } else return respond; } catch (Exception ex) { return ex.Message; } }