private bool Remove(PaymentVendor data, SqlConnection oConn) { int totalFiles = 0; string msg = ""; IList <Attached> files = repAtt.GetList(false, data.PayVendorCreatedBy, ref totalFiles, ref msg, data.PayVendorId); if (files != null) { foreach (var file in files) { File.Delete(file.AttachFilePath); } } string sql = "DELETE FROM PaymentVendors " + " WHERE (PayVendorId = @id)"; SqlCommand cmd = new SqlCommand(sql, oConn); cmd.Parameters.Add("@id", SqlDbType.Int).Value = data.PayVendorId; int number = Convert.ToInt32(cmd.ExecuteNonQuery()); if (number > 0) { return(true); } return(false); }
public bool Remove(PaymentVendor data, ref string msgError) { SqlConnection oConn = null; try { oConn = ConnManager.OpenConn(); } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); msgError = ex.Message; return(false); }; bool result; try { result = Remove(data, oConn); } catch (Exception ex) { ConnManager.CloseConn(oConn); LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); return(false); } ConnManager.CloseConn(oConn); return(result); }
public PaymentVendor Add(PaymentVendor data, ref string msgError) { SqlConnection oConn = null; try { oConn = ConnManager.OpenConn(); } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); throw; }; string sql = "INSERT INTO PaymentVendors ({0}) VALUES ({1}) " + "SELECT SCOPE_IDENTITY()"; EnumExtension.setListValues(data, "PayVendorId", ref sql); SqlCommand cmd = new SqlCommand(sql, oConn); int keyGenerated = 0; try { keyGenerated = Convert.ToInt32(cmd.ExecuteScalar()); } catch (Exception ex) { ConnManager.CloseConn(oConn); LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); msgError = ex.Message; return(null); } PaymentVendor returnData = Get(keyGenerated, oConn); ConnManager.CloseConn(oConn); return(returnData); }
public PaymentVendor Get(int id, ref string msgError) { SqlConnection oConn = null; try { oConn = ConnManager.OpenConn(); } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); msgError = ex.Message; return(null); }; PaymentVendor data = Get(id, oConn); ConnManager.CloseConn(oConn); return(data); }
public PaymentVendor Update(PaymentVendor data, ref string msgError) { SqlConnection oConn = null; try { oConn = ConnManager.OpenConn(); } catch (Exception ex) { LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); throw; }; string sql = "UPDATE PaymentVendors SET {0} WHERE PayVendorId = @id"; EnumExtension.setUpdateValues(data, "PayVendorId", ref sql); SqlCommand cmd = new SqlCommand(sql, oConn); cmd.Parameters.Add("@id", SqlDbType.Int).Value = data.PayVendorId; try { cmd.ExecuteNonQuery(); } catch (Exception ex) { ConnManager.CloseConn(oConn); LogManager.Write("ERROR:" + Environment.NewLine + "\tMETHOD = " + this.GetType().FullName + "." + MethodBase.GetCurrentMethod().Name + Environment.NewLine + "\tMESSAGE = " + ex.Message); msgError = ex.Message; return(null); } PaymentVendor returnData = Get(data.PayVendorId, oConn); ConnManager.CloseConn(oConn); return(returnData); }
public bool ReversePaid(int PayVendorId, string UserId, ref string msg) { PaymentVendor payHead = repPayHead.Get(PayVendorId, ref msg); return(repPayHead.Remove(payHead, ref msg)); }
public bool Pay(int VendorId, string UserId, Payment Paid, ref string msg) { decimal amount = 0, amountNB = 0, currencyRate = 0; string reference = ""; PaymentVendor payHeader = new PaymentVendor(); payHeader.PayVendorCreatedBy = UserId; payHeader.PayVendorCreatedDate = DateTime.Now; // Add into database pay Header payHeader = repPayHead.Add(payHeader, ref msg); //Insert into database details foreach (var pov in Paid.PaidDetail) { PaymentVendorDetail payDetail = new PaymentVendorDetail(); payDetail.PayModeID = pov.PayModeID; payDetail.PayVendorId = payHeader.PayVendorId; payDetail.PayVendorDetailAmount = pov.PayVendorDetailAmount; payDetail.PayVendorDetailAmountNB = pov.PayVendorDetailAmountNB; payDetail.PayVendorDetailCurrencyRate = pov.PayVendorDetailCurrencyRate; payDetail.PayVendorDetailReference = pov.PayVendorDetailReference; payDetail.AccountID = pov.AccountID; payDetail.PayVendorDetailDate = pov.PayVendorDetailDate; payDetail.PayVendorDetailComments = pov.PayVendorDetailComments; amount += pov.PayVendorDetailAmount; amountNB += pov.PayVendorDetailAmountNB; currencyRate = pov.PayVendorDetailCurrencyRate; reference += "/" + pov.PayVendorDetailReference; payDetail = repPayDetail.Add(payDetail, ref msg); } // insert details to pay decimal thisPaid = 0, thisPaidNB = 0; foreach (var pov in Paid.POVList) { thisPaid = pov.x_InvoiceVendorBalance.GetValueOrDefault(); thisPaidNB = pov.x_InvoiceVendorBalanceNB.GetValueOrDefault(); POVendorsDetail povDetail = new POVendorsDetail(); povDetail.POVDetailAmount = -thisPaid; povDetail.POVDetailAmountNB = -thisPaidNB; povDetail.POVDetailCreatedBy = UserId; povDetail.POVDetailCreatedDate = DateTime.Now; povDetail.POVDetailCurrencyRate = currencyRate; povDetail.POVDetailDate = DateTime.Now; povDetail.POVDetailPaymentNumber = !string.IsNullOrEmpty(reference) ? reference.Substring(1) : reference; povDetail.POVId = pov.POVId; povDetail.POVDetailType = "PB"; povDetail.PayVendorId = payHeader.PayVendorId; povDetail = repPOV.AddDetail(povDetail, ref msg); } foreach (var file in Paid.Files) { IDictionary <string, object> data = new Dictionary <string, object>(); data["AttachId"] = file.AttachId; data["AttachDirty"] = false; data["PayVendorId"] = payHeader.PayVendorId; repAtt.Update(data, UserId, ref msg); } //msg = String.Format("{0:#,###.00} and {1:#,###.00}", amount, amountNB); return(true); }