public async Task <IActionResult> Edit(int id, [Bind("CreditTypeId,Name,MonthTerm,Interest")] CreditType creditType) { if (id != creditType.CreditTypeId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(creditType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CreditTypeExists(creditType.CreditTypeId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(creditType)); }
private void SendRequest_Click(object sender, RoutedEventArgs e) { if (Validate()) { CreditType ct = _creditTypeBusinessComponent.GetAllActiveCreditTypes().Where(x => x.Name == CreditCTypeBox.SelectedValue.ToString()).FirstOrDefault(); bool MoreThanMAX = ct.MaxAmount < Convert.ToInt32(CreditAmount.Text); bool LessThanMIN = ct.MinAmount > Convert.ToInt32(CreditAmount.Text); if (Validate() && !MoreThanMAX && !LessThanMIN) { MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure?", "Accept Confirmation", MessageBoxButton.YesNo); if (messageBoxResult == MessageBoxResult.Yes) { int _clientId = _clientBusinessComponent.GetAll().Where(x => x.UserId == _userId).FirstOrDefault().ClientId; CreditType ctype = _creditTypeBusinessComponent.GetAllActiveCreditTypes().Where(x => x.Name == CreditCTypeBox.SelectedValue.ToString()).FirstOrDefault(); _requestBusinessComponent.Add(_clientId, null, null, ctype.CreditTypeId, Entities.Enums.RequestStatus.Created, Convert.ToDecimal(CreditAmount.Text), Convert.ToDecimal(CreditSalary.Text), ""); } ClearRequestListView(); FillRequestListView(); } string error = ""; if (LessThanMIN) { error += "Amount shold be more than " + ct.MinAmount + Environment.NewLine; } if (MoreThanMAX) { error += "Amount shold be less than " + ct.MaxAmount + Environment.NewLine; } if (error != "") { MessageBox.Show(error); } } }
private void CreditTypeAddButton_Click(object sender, RoutedEventArgs e) { var validationResult = CreditTypeValidation.Validate( NameField.Text, TimeMonthField.Text, PercentPerYearField.Text, (string)CurrencyComboBox.SelectedValue, FinePercentField.Text, MinAmountField.Text, MaxAmountField.Text); if (validationResult.IsValid) { var creditType = new CreditType() { Name = NameField.Text, TimeMonths = int.Parse(TimeMonthField.Text), PercentPerYear = decimal.Parse(PercentPerYearField.Text), Currency = "USD", // FinePercent = decimal.Parse(FinePercentField.Text), MinAmount = decimal.Parse(MinAmountField.Text), MaxAmount = decimal.Parse(MaxAmountField.Text) }; _creditTypeBc.Add(creditType); MessageBox.Show("Added successfully"); this.Close(); } else { MessageBox.Show(validationResult.Error); } }
/// <summary> /// Updates or creates a resource based on the resource identifier. The PUT operation is used to update or create a resource by identifier. If the resource doesn't exist, the resource will be created using that identifier. Additionally, natural key values cannot be changed using this operation, and will not be modified in the database. If the resource "id" is provided in the JSON body, it will be ignored as well. /// </summary> /// <param name="id">A resource identifier specifying the resource to be updated.</param> /// <param name="IfMatch">The ETag header value used to prevent the PUT from updating a resource modified by another consumer.</param> /// <param name="body">The JSON representation of the "creditType" resource to be updated.</param> /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns> public IRestResponse PutCreditType(string id, string IfMatch, CreditType body) { var request = new RestRequest("/creditTypes/{id}", Method.PUT); request.RequestFormat = DataFormat.Json; request.AddUrlSegment("id", id); // verify required params are set if (id == null || body == null) { throw new ArgumentException("API method call is missing required parameters"); } request.AddHeader("If-Match", IfMatch); request.AddBody(body); request.Parameters.First(param => param.Type == ParameterType.RequestBody).Name = "application/json"; var response = client.Execute(request); var location = response.Headers.FirstOrDefault(x => x.Name == "Location"); if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString())) { body.id = location.Value.ToString().Split('/').Last(); } return(response); }
public Int32 SetBillingAsPrinted(CreditType CreditType, Int64 ContactIDorGuarantorID, DateTime BillingDate, string BillingFile) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = "UPDATE tblCreditBillHeader SET " + "IsBillPrinted = 1, BillingFile = @BillingFile " + "WHERE ContactID = @ContactID AND BillingDate = @BillingDate;"; // do an override if group if (CreditType == RetailPlus.CreditType.Group) SQL = "UPDATE tblCreditBillHeader SET " + "IsBillPrinted = 1, BillingFile = @BillingFile " + "WHERE GuarantorID = @ContactID AND BillingDate = @BillingDate;"; cmd.Parameters.AddWithValue("BillingFile", BillingFile); cmd.Parameters.AddWithValue("ContactID", ContactIDorGuarantorID); cmd.Parameters.AddWithValue("BillingDate", BillingDate.ToString("yyyy-MM-dd")); cmd.CommandText = SQL; return base.ExecuteNonQuery(cmd); } catch (Exception ex) { throw base.ThrowException(ex); } }
/// <summary> /// Saves entity changes to the database /// </summary> /// <param name="item"></param> /// <returns>updated entity, or null if the entity is deleted</returns> public CreditType Persist(CreditType item) { if (item.Id == 0 && item.IsMarkedForDeletion) { return(null); } var connString = ConfigurationManager.ConnectionStrings["AppConnection"].ConnectionString; using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); if (item.IsMarkedForDeletion) { DeleteEntity(item, conn); item = null; } else if (item.Id == 0) { InsertEntity(item, conn); item.IsDirty = false; } else if (item.IsDirty) { UpdateEntity(item, conn); item.IsDirty = false; } } return(item); }
public Int32 SetBillingAsPrinted(CreditType CreditType, Int64 ContactIDorGuarantorID, DateTime BillingDate, string BillingFile) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = "UPDATE tblCreditBillHeader SET " + "IsBillPrinted = 1, BillingFile = @BillingFile " + "WHERE ContactID = @ContactID AND BillingDate = @BillingDate;"; // do an override if group if (CreditType == RetailPlus.CreditType.Group) { SQL = "UPDATE tblCreditBillHeader SET " + "IsBillPrinted = 1, BillingFile = @BillingFile " + "WHERE GuarantorID = @ContactID AND BillingDate = @BillingDate;"; } cmd.Parameters.AddWithValue("BillingFile", BillingFile); cmd.Parameters.AddWithValue("ContactID", ContactIDorGuarantorID); cmd.Parameters.AddWithValue("BillingDate", BillingDate.ToString("yyyy-MM-dd")); cmd.CommandText = SQL; return(base.ExecuteNonQuery(cmd)); } catch (Exception ex) { throw base.ThrowException(ex); } }
public Int32 CloseCurrentBill(CreditType CreditType, string CardTypeCode) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = "CALL procProcessCreditBillsClose(@CardTypeCode);"; // overried if group if (CreditType == RetailPlus.CreditType.Group) { SQL = "CALL procProcessCreditBillsWGClose(@CardTypeCode);"; } cmd.Parameters.AddWithValue("CardTypeCode", CardTypeCode); cmd.CommandText = SQL; return(base.ExecuteNonQuery(cmd)); } catch (Exception ex) { throw base.ThrowException(ex); } }
public bool IsUsed(CreditType creditType) { return (_unitOfWork.CreditRepository.GetAll() .Where(x => x.IsRepaid == false) .Any(x => x.CreditType.CreditTypeId == creditType.CreditTypeId)); }
private static void SetCommonParameters(CreditType item, SqlCommand cmd) { cmd.Parameters.AddWithValue("@Code", item.Code); cmd.Parameters.AddWithValue("@Name", item.Name); cmd.Parameters.AddWithValue("@IsInactive", item.IsInactive); cmd.Parameters.AddWithValue("@DisplayOrder", item.DisplayOrder); }
public List <CardTypeDetails> ListUnPrintedCreditCardTypes(CreditType CreditType = CreditType.Both, string SortField = "CardTypeCode", System.Data.SqlClient.SortOrder SortOrder = System.Data.SqlClient.SortOrder.Ascending, Int32 limit = 0) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = SQLSelectCreditCardTypes() + ""; SQL += "WHERE CBH.IsBillPrinted = 0 "; if (CreditType == CreditType.Group) { SQL += "AND CBH.GuarantorID <> 0 "; } else if (CreditType == CreditType.Individual) { SQL += "AND CBH.GuarantorID = 0 "; } SQL += "ORDER BY " + (!string.IsNullOrEmpty(SortField) ? SortField : "CardTypeCode") + " "; SQL += SortOrder == System.Data.SqlClient.SortOrder.Ascending ? "ASC " : "DESC "; SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " "; cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); List <CardTypeDetails> lstRetValue = new List <CardTypeDetails>(); foreach (DataRow dr in dt.Rows) { lstRetValue.Add(new Data.CardTypeDetails() { CardTypeID = Int16.Parse(dr["CreditCardTypeID"].ToString()), CardTypeCode = dr["CardTypeCode"].ToString(), CardTypeName = dr["CardTypeName"].ToString(), CreditFinanceCharge = decimal.Parse(dr["CreditFinanceCharge"].ToString()), CreditLatePenaltyCharge = decimal.Parse(dr["CreditLatePenaltyCharge"].ToString()), CreditMinimumAmountDue = decimal.Parse(dr["CreditMinimumAmountDue"].ToString()), CreditMinimumPercentageDue = decimal.Parse(dr["CreditMinimumPercentageDue"].ToString()), CreditFinanceCharge15th = decimal.Parse(dr["CreditFinanceCharge15th"].ToString()), CreditLatePenaltyCharge15th = decimal.Parse(dr["CreditLatePenaltyCharge15th"].ToString()), CreditMinimumAmountDue15th = decimal.Parse(dr["CreditMinimumAmountDue15th"].ToString()), CreditMinimumPercentageDue15th = decimal.Parse(dr["CreditMinimumPercentageDue15th"].ToString()), CreditPurcStartDateToProcess = DateTime.Parse(dr["CreditPurcStartDateToProcess"].ToString()), CreditPurcEndDateToProcess = DateTime.Parse(dr["CreditPurcEndDateToProcess"].ToString()), CreditCutOffDate = DateTime.Parse(dr["CreditCutOffDate"].ToString()), CreditCardType = (CreditCardTypes)Enum.Parse(typeof(CreditCardTypes), dr["CreditCardType"].ToString()), WithGuarantor = bool.Parse(dr["WithGuarantor"].ToString()), BillingDate = DateTime.Parse(dr["BillingDate"].ToString()) }); } return(lstRetValue); } catch (Exception ex) { throw base.ThrowException(ex); } }
public void CreateOrUpdate(CreditType creditType) { lock (Look) { _db.CreditTypes.AddOrUpdate(creditType); _db.SaveChanges(); } }
public ActionResult DeleteConfirmed(int id) { CreditType creditType = db.CreditTypes.Find(id); db.CreditTypes.Remove(creditType); db.SaveChanges(); return(RedirectToAction("Index")); }
private void UpdateComboCreditType(String selectedLanguage, String selectValue) { this.comboCreditType.DataSource = CreditType.GetCreditType(selectedLanguage); this.comboCreditType.DataTextField = "text"; this.comboCreditType.DataValueField = "value"; this.comboCreditType.DataBind(); this.comboCreditType.SelectedValue = selectValue; }
public bool Draw(CreditType type, ulong value) { if (this[type] < value) return false; this[type] -= value; return true; }
internal static void DeleteEntity(CreditType item, SqlConnection conn) { using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "delete CreditType where Id = @Id"; cmd.Parameters.AddWithValue("@Id", item.Id); cmd.ExecuteNonQuery(); } }
public ActionResult Edit([Bind(Include = "ID,Name,Rates,Commission")] CreditType creditType) { if (ModelState.IsValid) { db.Entry(creditType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(creditType)); }
public void beginCredits() { if (!started) { // Sanitize input speed = Mathf.Clamp(speed, 50, 1000); // Calculate margin height = (int)GetComponent <RectTransform>().rect.height; // Load from XML and calculate position XmlReader reader = XmlReader.Create(new StringReader(creditsFile.text)); while (reader.ReadToFollowing("credit")) { CreditType type = CreditType.EmptySpace; string data = ""; string data2 = ""; while (reader.MoveToNextAttribute()) { if (reader.Name == "type") { type = CreditLine.textToType(reader.Value); } else if (reader.Name == "data") { data = reader.Value; } else if (reader.Name == "data2") { data2 = reader.Value; } } if (type == CreditType.EmptySpace) { int n = Mathf.Clamp(int.Parse(data), 1, 100); for (int i = 0; i < n; ++i) { lines.Add(new CreditLine(CreditType.EmptySpace, "", "")); } } else { lines.Add(new CreditLine(type, data, data2)); } } count = lines.Count; // Start started = true; spawnNext(); } }
public bool Draw(CreditType type, ulong value) { if (this[type] < value) { return(false); } this[type] -= value; return(true); }
public async Task <IActionResult> Create([Bind("CreditTypeId,Name,MonthTerm,Interest")] CreditType creditType) { if (ModelState.IsValid) { _context.Add(creditType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(creditType)); }
public ActionResult Create([Bind(Include = "ID,Name,Rates,Commission")] CreditType creditType) { if (ModelState.IsValid) { db.CreditTypes.Add(creditType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(creditType)); }
// Utils functions for CreditType public static string typeToText(CreditType t) { switch(t) { case CreditType.Title: return "titleHLD"; case CreditType.SingleColumn: return "singlecolumn"; case CreditType.Image: return "texture"; case CreditType.EmptySpace: return "space"; default: return "twocolumns"; } }
public ulong this[CreditType type] { get { return(credits[(int)type]); } set { credits[(int)type] = value; } }
public ulong this[CreditType type] { get { return credits[(int)type]; } set { credits[(int)type] = value; } }
public CreditBillDetails Details(CreditType CreditType = CreditType.Both, DateTime?BillingDate = null, Int16 CreditCardTypeID = 0) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = SQLSelect() + "WHERE 1=1 "; if (CreditType == CreditType.Group) { SQL += "AND WithGuarantor = 1 "; } else if (CreditType == CreditType.Individual) { SQL += "AND WithGuarantor = 0 "; } if (BillingDate.GetValueOrDefault(Constants.C_DATE_MIN_VALUE) == Constants.C_DATE_MIN_VALUE) { SQL += "AND BillingDate = (SELECT MAX(BillingDate) FROM tblCreditBills) "; } else { SQL += "AND BillingDate = @BillingDate "; cmd.Parameters.AddWithValue("BillingDate", BillingDate.GetValueOrDefault(Constants.C_DATE_MIN_VALUE)); } if (CreditCardTypeID != 0) { SQL += "AND CreditCardTypeID = @CreditCardTypeID "; cmd.Parameters.AddWithValue("CreditCardTypeID", CreditCardTypeID); } SQL += "ORDER BY CreditBillID "; SQL += "ASC "; SQL += "LIMIT 1 "; cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); CreditBillDetails Details = setDetails(dt); return(Details); } catch (Exception ex) { throw base.ThrowException(ex); } }
// GET: CreditTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CreditType creditType = db.CreditTypes.Find(id); if (creditType == null) { return(HttpNotFound()); } return(View(creditType)); }
public System.Data.DataTable ListBillingDateAsDataTable(CreditType CreditType, Int64 CustomerID = 0, DateTime?BillingDate = null, Int16 CreditCardTypeID = 0, string SortField = "BillingDate", System.Data.SqlClient.SortOrder SortOrder = System.Data.SqlClient.SortOrder.Descending, Int32 limit = 0) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = "SELECT DISTINCT DATE_FORMAT(CBH.BillingDate, '%Y-%m-%d') BillingDate, CBH.BillingFile FROM tblCreditBillHeader CBH " + "INNER JOIN tblCreditBills CB ON CB.CreditBillID = CBH.CreditBillID WHERE 1=1 "; if (CreditType == CreditType.Individual) { SQL += "AND CB.WithGuarantor = 0 "; } if (CreditType == CreditType.Group) { SQL += "AND CB.WithGuarantor <> 0 "; } if (CustomerID != 0) { SQL += "AND CBH.ContactID = @CustomerID "; cmd.Parameters.AddWithValue("CustomerID", CustomerID); } if (BillingDate.GetValueOrDefault(Constants.C_DATE_MIN_VALUE) != Constants.C_DATE_MIN_VALUE) { SQL += "AND CBH.BillingDate = @BillingDate "; cmd.Parameters.AddWithValue("BillingDate", BillingDate); } if (CreditCardTypeID != 0) { SQL += "AND CB.CreditCardTypeID = @CreditCardTypeID "; cmd.Parameters.AddWithValue("CreditCardTypeID", CreditCardTypeID); } SQL += "ORDER BY " + (!string.IsNullOrEmpty(SortField) ? SortField : "BillingDate") + " "; SQL += SortOrder == System.Data.SqlClient.SortOrder.Ascending ? "ASC " : "DESC "; SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " "; cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); return(dt); } catch (Exception ex) { throw base.ThrowException(ex); } }
// Utils functions for CreditType public static string typeToText(CreditType t) { switch (t) { case CreditType.Title: return("titleHLD"); case CreditType.SingleColumn: return("singlecolumn"); case CreditType.Image: return("texture"); case CreditType.EmptySpace: return("space"); default: return("twocolumns"); } }
public void SaveUpdateCreditType(CreditType model) { using (var context = new FinanceEntities()) { if (model.Id == 0) { context.CreditType.Add(model); } else { context.Entry(model).State = EntityState.Modified;; } context.SaveChanges(); } }
private void FillCreditTypeAndSubtypeHash(string creditType, string creditSubtype) { if (CreditType.Contains(creditType) == false) { CreditType.Add(creditType); CreditSubtype.Add(creditType, new HashSet <string>()); } var creditSubTypes = CreditSubtype[creditType]; if (creditSubTypes.Contains(creditSubtype) == false) { creditSubTypes.Add(creditSubtype); } }
internal static void InsertEntity(CreditType item, SqlConnection conn) { using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandType = System.Data.CommandType.Text; var sql = new StringBuilder(); sql.Append("insert CreditType (Code, Name, IsInactive, DisplayOrder)"); sql.Append("values (@Code, @Name, @IsInactive, @DisplayOrder);"); sql.Append("select cast( scope_identity() as int);"); cmd.CommandText = sql.ToString(); SetCommonParameters(item, cmd); item.Id = (int)cmd.ExecuteScalar(); } }
private void CTypeListView_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { CTypeListView clv = (CTypeListView)CTypeListView.SelectedItem; CreditType ctype = _creditTypeBusinessComponent.GetAllCreditTypes().Where(x => x.Name == clv.CTypeName).FirstOrDefault(); CTypeName.Text = ctype.Name; CTypeTimeMonths.Text = ctype.TimeMonths.ToString(); CTypePercentPerYear.Text = ctype.PercentPerYear.ToString(); CTypeCurrency.Text = ctype.Currency; CTypeFinePercent.Text = ctype.FinePercent.ToString(); CTypeMinAmount.Text = ctype.MinAmount.ToString(); CTypeMaxAmount.Text = ctype.MaxAmount.ToString(); CTypeIsAvailable.Text = ctype.IsAvailable.ToString(); } catch { } }
public IEnumerable <CreditType> Fetch(object criteria = null) { var data = new List <CreditType>(); var connString = ConfigurationManager .ConnectionStrings["AppConnection"].ConnectionString; using (SqlConnection conn = new SqlConnection(connString)) { conn.Open(); using (var cmd = conn.CreateCommand()) { cmd.CommandType = System.Data.CommandType.Text; if (criteria == null) { cmd.CommandText = "select * from CreditType"; } else if (criteria is int) { cmd.CommandText = "select * from CreditType where Id = @Id"; cmd.Parameters.AddWithValue("@Id", (int)criteria); } else { var msg = String.Format( "CreditTypeRepository: Unknown criteria type: {0}", criteria); throw new InvalidOperationException(msg); } var dr = cmd.ExecuteReader(); while (dr.Read()) { var g = new CreditType(); g.Id = dr.AsInt32("Id"); g.Code = dr.AsString("Code"); g.Name = dr.AsString("Name"); g.IsInactive = dr.AsBoolean("IsInactive"); g.DisplayOrder = dr.AsInt32("DisplayOrder"); g.IsDirty = false; data.Add(g); } } } return(data); }
public VLPayment() { m_paymentId = default(Int32); m_client = default(Int32); m_comment = default(string); m_paymentType = default(PaymentType); m_paymentDate = default(DateTime); m_customCode1 = default(string); m_customCode2 = default(string); m_isActive = default(Boolean); m_isTimeLimited = default(Boolean); m_validFromDt = null; m_validToDt = null; m_creditType = default(CreditType); m_quantity = default(Int32); m_quantityUsed = default(Int32); m_attributeFlags = default(Int32); }
public FlatRedBall.Glue.StateInterpolation.Tweener InterpolateToRelative(CreditType toState, double secondsToTake, FlatRedBall.Glue.StateInterpolation.InterpolationType interpolationType, FlatRedBall.Glue.StateInterpolation.Easing easing, object owner = null) { Gum.DataTypes.Variables.StateSave current = GetCurrentValuesOnState(toState); Gum.DataTypes.Variables.StateSave toAsStateSave = AddToCurrentValuesWithState(toState); FlatRedBall.Glue.StateInterpolation.Tweener tweener = new FlatRedBall.Glue.StateInterpolation.Tweener(from: 0, to: 1, duration: (float)secondsToTake, type: interpolationType, easing: easing); if (owner == null) { tweener.Owner = this; } else { tweener.Owner = owner; } tweener.PositionChanged = newPosition => this.InterpolateBetween(current, toAsStateSave, newPosition); tweener.Ended += () => this.CurrentCreditTypeState = toState; tweener.Start(); StateInterpolationPlugin.TweenerManager.Self.Add(tweener); return(tweener); }
public void CreditTypeRepository_InsertUpdateDelete() { // Arrange var repo = new CreditTypeRepository(); var newItem = new CreditType { Code = "TestCode", Name = "TestName", IsInactive = false, DisplayOrder = 99 }; var item = repo.Persist(newItem); var newId = item.Id; // Act for Update item.Name = "XYZ"; item.Code = "ABC"; item.IsInactive = true; item.DisplayOrder = 999; item.IsDirty = true; var updatedItem = repo.Persist(item); Assert.IsTrue(updatedItem.IsDirty == false); Assert.IsTrue(updatedItem.Name == "XYZ"); Assert.IsTrue(updatedItem.Code == "ABC"); Assert.IsTrue(updatedItem.IsInactive); Assert.IsTrue(updatedItem.DisplayOrder == 999); // Assert for Update var refetch = repo.Fetch(newId).First(); Assert.IsTrue(refetch.Name == "XYZ"); // Clean-up (Act for Delete) item.IsMarkedForDeletion = true; repo.Persist(item); // Assert for Delete var result = repo.Fetch(newId); Assert.IsFalse(result.Any()); }
public CreditLine(CreditType type, string data, string data2) { this.type = type; this.data = data; this.data2 = data2; }
public void Add(CreditType type, ulong value) { // MH: add overflow check this[type] += value; }
public System.Data.DataTable ListAsDataTable(Int64 GuarantorID = 0, Int64 ContactID = 0, Int16 CreditCardTypeID = 0, CreditType CreditType = CreditType.Both, DateTime? BillingDate = null, bool CheckIsBillPrinted = false, bool IsBillPrinted = false, string SortField = "CreditBillHeaderID", System.Data.SqlClient.SortOrder SortOrder = System.Data.SqlClient.SortOrder.Ascending, Int32 limit = 0) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = SQLSelect() + ""; SQL += "WHERE 1=1 "; if (CheckIsBillPrinted) { SQL += "AND IsBillPrinted = @IsBillPrinted "; cmd.Parameters.AddWithValue("IsBillPrinted", IsBillPrinted ? 1 : 0); } if (GuarantorID != 0) { SQL += "AND CBH.GuarantorID = @GuarantorID "; cmd.Parameters.AddWithValue("GuarantorID", GuarantorID); } if (ContactID != 0) { SQL += "AND CBH.ContactID = @ContactID "; cmd.Parameters.AddWithValue("ContactID", ContactID); } if (CreditType == CreditType.Group) { SQL += "AND CBH.GuarantorID <> 0 "; } else if (CreditType == CreditType.Individual) { SQL += "AND CBH.GuarantorID = 0 "; } if (CreditCardTypeID != 0) { SQL += "AND CBL.CreditCardTypeID = @CreditCardTypeID "; cmd.Parameters.AddWithValue("CreditCardTypeID", CreditCardTypeID); } if (BillingDate.GetValueOrDefault(Constants.C_DATE_MIN_VALUE) == Constants.C_DATE_MIN_VALUE) { SQL += "AND CBL.BillingDate = (SELECT MAX(BillingDate) FROM tblCreditBills) "; } else { SQL += "AND CBL.BillingDate = @BillingDate "; cmd.Parameters.AddWithValue("BillingDate", BillingDate.GetValueOrDefault(Constants.C_DATE_MIN_VALUE)); } SQL += "ORDER BY " + (!string.IsNullOrEmpty(SortField) ? SortField : "CreditBillHeaderID") + " "; SQL += SortOrder == System.Data.SqlClient.SortOrder.Ascending ? "ASC " : "DESC "; SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " "; cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); return dt; } catch (Exception ex) { throw base.ThrowException(ex); } }
public List<BillingDetails> List(Int64 GuarantorID = 0, Int64 ContactID = 0, Int16 CreditCardTypeID = 0, CreditType CreditType = CreditType.Both, DateTime? BillingDate = null, bool CheckIsBillPrinted = false, bool IsBillPrinted = false, string SortField = "ContactID", System.Data.SqlClient.SortOrder SortOrder = System.Data.SqlClient.SortOrder.Ascending, Int32 limit = 0) { try { System.Data.DataTable dt = ListAsDataTable(GuarantorID, ContactID, CreditCardTypeID, CreditType, BillingDate, CheckIsBillPrinted, IsBillPrinted, SortField, SortOrder, limit); List<BillingDetails> lstRetValue = new List<BillingDetails>(); foreach (DataRow dr in dt.Rows) { lstRetValue.Add(setDetails(dr)); } return lstRetValue; } catch (Exception ex) { throw base.ThrowException(ex); } }
public CreditBillDetails Details(CreditType CreditType = CreditType.Both, DateTime? BillingDate = null, Int16 CreditCardTypeID = 0) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = SQLSelect() + "WHERE 1=1 "; if (CreditType == CreditType.Group) { SQL += "AND WithGuarantor = 1 "; } else if (CreditType == CreditType.Individual) { SQL += "AND WithGuarantor = 0 "; } if (BillingDate.GetValueOrDefault(Constants.C_DATE_MIN_VALUE) == Constants.C_DATE_MIN_VALUE) { SQL += "AND BillingDate = (SELECT MAX(BillingDate) FROM tblCreditBills) "; } else { SQL += "AND BillingDate = @BillingDate "; cmd.Parameters.AddWithValue("BillingDate", BillingDate.GetValueOrDefault(Constants.C_DATE_MIN_VALUE)); } if (CreditCardTypeID != 0) { SQL += "AND CreditCardTypeID = @CreditCardTypeID "; cmd.Parameters.AddWithValue("CreditCardTypeID", CreditCardTypeID); } SQL += "ORDER BY CreditBillID "; SQL += "ASC "; SQL += "LIMIT 1 "; cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); CreditBillDetails Details = setDetails(dt); return Details; } catch (Exception ex) { throw base.ThrowException(ex); } }
public List<CardTypeDetails> ListUnPrintedCreditCardTypes(CreditType CreditType = CreditType.Both, string SortField = "CardTypeCode", System.Data.SqlClient.SortOrder SortOrder = System.Data.SqlClient.SortOrder.Ascending, Int32 limit = 0) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = SQLSelectCreditCardTypes() + ""; SQL += "WHERE CBH.IsBillPrinted = 0 "; if (CreditType == CreditType.Group) { SQL += "AND CBH.GuarantorID <> 0 "; } else if (CreditType == CreditType.Individual) { SQL += "AND CBH.GuarantorID = 0 "; } SQL += "ORDER BY " + (!string.IsNullOrEmpty(SortField) ? SortField : "CardTypeCode") + " "; SQL += SortOrder == System.Data.SqlClient.SortOrder.Ascending ? "ASC " : "DESC "; SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " "; cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); List<CardTypeDetails> lstRetValue = new List<CardTypeDetails>(); foreach (DataRow dr in dt.Rows) { lstRetValue.Add(new Data.CardTypeDetails() { CardTypeID = Int16.Parse(dr["CreditCardTypeID"].ToString()), CardTypeCode = dr["CardTypeCode"].ToString(), CardTypeName = dr["CardTypeName"].ToString(), CreditFinanceCharge = decimal.Parse(dr["CreditFinanceCharge"].ToString()), CreditLatePenaltyCharge = decimal.Parse(dr["CreditLatePenaltyCharge"].ToString()), CreditMinimumAmountDue = decimal.Parse(dr["CreditMinimumAmountDue"].ToString()), CreditMinimumPercentageDue = decimal.Parse(dr["CreditMinimumPercentageDue"].ToString()), CreditFinanceCharge15th = decimal.Parse(dr["CreditFinanceCharge15th"].ToString()), CreditLatePenaltyCharge15th = decimal.Parse(dr["CreditLatePenaltyCharge15th"].ToString()), CreditMinimumAmountDue15th = decimal.Parse(dr["CreditMinimumAmountDue15th"].ToString()), CreditMinimumPercentageDue15th = decimal.Parse(dr["CreditMinimumPercentageDue15th"].ToString()), CreditPurcStartDateToProcess = DateTime.Parse(dr["CreditPurcStartDateToProcess"].ToString()), CreditPurcEndDateToProcess = DateTime.Parse(dr["CreditPurcEndDateToProcess"].ToString()), CreditCutOffDate = DateTime.Parse(dr["CreditCutOffDate"].ToString()), CreditCardType = (CreditCardTypes)Enum.Parse(typeof(CreditCardTypes), dr["CreditCardType"].ToString()), WithGuarantor = bool.Parse(dr["WithGuarantor"].ToString()), BillingDate = DateTime.Parse(dr["BillingDate"].ToString()) }); } return lstRetValue; } catch (Exception ex) { throw base.ThrowException(ex); } }
public Int32 CloseCurrentBill(CreditType CreditType, string CardTypeCode) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = "CALL procProcessCreditBillsClose(@CardTypeCode);"; // overried if group if (CreditType == RetailPlus.CreditType.Group) SQL = "CALL procProcessCreditBillsWGClose(@CardTypeCode);"; cmd.Parameters.AddWithValue("CardTypeCode", CardTypeCode); cmd.CommandText = SQL; return base.ExecuteNonQuery(cmd); } catch (Exception ex) { throw base.ThrowException(ex); } }
public bool creditAid(string onr, string aid, CreditType ctor) { OrderRowDefinitions.OwnFee ownfee = new OrderRowDefinitions.OwnFee(); bool bOK = false; switch (ctor) { case CreditType.OnlyPatient: ownfee = getPatientsOwnFeeOrderNo(onr, aid); if (ownfee.OrderNo != null) { OwnFee of = new OwnFee(); OwnFee.OwnFeeResult ofr = of.creditRowOnPatientsOrder(ownfee.PatientsOrderNo, ownfee.PatientsRowNo); orText.addOwnFeeConnection(ofr.OrderNo, ofr.OrderRow, onr.PadRight(6) + " - " + aid + " (hjälpmedelsid)"); try { if (ECS.noNULL(ownfee.PaymentTerms).Equals(Config.BetVillkEaKont)) { //Config con = new Config(mBolag); string[] s = Config.getReceipt().Split('-'); string mDokGen = s[0]; string mReport = s[1]; printInvoice(s[0], s[1], ofr.FsNo); } else { //Config con = new Config(mBolag); string[] s = Config.getInvoice().Split('-'); string mDokGen = s[0]; string mReport = s[1]; printInvoice(s[0], s[1], ofr.FsNo); } } catch (Exception ex) { Log4Net.Logger.loggError(ex, "Problem when printing after creation of credit on OnlyPatient", Config.User, ""); } bOK = true; } break; case CreditType.OnlyInvoiceCustomer: creditAidOnOriginalOrder(onr, aid); bOK = true; break; case CreditType.Both: ownfee = getPatientsOwnFeeOrderNo(onr, aid); if (ownfee.OrderNo != null) { OwnFee of = new OwnFee(); OwnFee.OwnFeeResult ofr = of.creditRowOnPatientsOrder(ownfee.PatientsOrderNo, ownfee.PatientsRowNo); orText.addOwnFeeConnection(ofr.OrderNo, ofr.OrderRow, onr.PadRight(6) + " - " + aid + " (hjälpmedelsid)"); try { if (ECS.noNULL(ownfee.PaymentTerms).Equals(Config.BetVillkEaKont)) { //Config con = new Config(mBolag); string[] s = Config.getReceipt().Split('-'); string mDokGen = s[0]; string mReport = s[1]; printInvoice(s[0], s[1], ofr.FsNo); } else { //Config con = new Config(mBolag); string[] s = Config.getInvoice().Split('-'); string mDokGen = s[0]; string mReport = s[1]; printInvoice(s[0], s[1], ofr.FsNo); } } catch (Exception ex) { Log4Net.Logger.loggError(ex, "Problem when printing after creation of credit on Both", Config.User, ""); } bOK = true; creditAidOnOriginalOrder(onr, aid); } break; default: break; } return bOK; }
public System.Data.DataTable ListBillingDateAsDataTable(CreditType CreditType, Int64 CustomerID = 0, DateTime? BillingDate = null, Int16 CreditCardTypeID = 0, string SortField = "BillingDate", System.Data.SqlClient.SortOrder SortOrder = System.Data.SqlClient.SortOrder.Descending, Int32 limit = 0) { try { MySqlCommand cmd = new MySqlCommand(); cmd.CommandType = System.Data.CommandType.Text; string SQL = "SELECT DISTINCT DATE_FORMAT(CBH.BillingDate, '%Y-%m-%d') BillingDate, CBH.BillingFile FROM tblCreditBillHeader CBH " + "INNER JOIN tblCreditBills CB ON CB.CreditBillID = CBH.CreditBillID WHERE 1=1 "; if (CreditType == CreditType.Individual) { SQL += "AND CB.WithGuarantor = 0 "; } if (CreditType == CreditType.Group) { SQL += "AND CB.WithGuarantor <> 0 "; } if (CustomerID != 0) { SQL += "AND CBH.ContactID = @CustomerID "; cmd.Parameters.AddWithValue("CustomerID", CustomerID); } if (BillingDate.GetValueOrDefault(Constants.C_DATE_MIN_VALUE) != Constants.C_DATE_MIN_VALUE) { SQL += "AND CBH.BillingDate = @BillingDate "; cmd.Parameters.AddWithValue("BillingDate", BillingDate); } if (CreditCardTypeID != 0) { SQL += "AND CB.CreditCardTypeID = @CreditCardTypeID "; cmd.Parameters.AddWithValue("CreditCardTypeID", CreditCardTypeID); } SQL += "ORDER BY " + (!string.IsNullOrEmpty(SortField) ? SortField : "BillingDate") + " "; SQL += SortOrder == System.Data.SqlClient.SortOrder.Ascending ? "ASC " : "DESC "; SQL += limit == 0 ? "" : "LIMIT " + limit.ToString() + " "; cmd.CommandText = SQL; string strDataTableName = "tbl" + this.GetType().FullName.Split(new Char[] { '.' })[this.GetType().FullName.Split(new Char[] { '.' }).Length - 1]; System.Data.DataTable dt = new System.Data.DataTable(strDataTableName); base.MySqlDataAdapterFill(cmd, dt); return dt; } catch (Exception ex) { throw base.ThrowException(ex); } }