public static Cards GetChargeCards(string typeCode, decimal parValue) { try { lock (lockObj) { ChargeAccountType AccountType = SQLChargeAccountType.GetChargeAccountType(p => p.Code == typeCode).FirstOrDefault(); Cards cards = GetCards(p => p.ChargeAccountTypeID == AccountType.ChargeAccountTypeID && p.IsAvailable == true && p.ReChargeStatus == 0 && p.Price == parValue).FirstOrDefault(); cards.ReChargeStatus = 1; if (UpdateCards(cards)) { return(cards); } } } catch (Exception) { } return(null); }
public static OrderChargeAccount GetChargeAccount_i(string typeCode, bool isReadonly) { try { ChargeAccountType AccountType = SQLChargeAccountType.GetChargeAccountType(p => p.Code == typeCode).FirstOrDefault(); OrderChargeAccount orderChargeAccount = GetOrderChargeAccount(p => p.ChargeAccountTypeID == AccountType.ChargeAccountTypeID && p.IsAvailable == true && p.IsUsing == false).OrderBy(p => p.UseTimes).FirstOrDefault(); if (orderChargeAccount == null) { return(null); } if (isReadonly) { orderChargeAccount.IsUsing = true; if (UpdateOrderChargeAccount(orderChargeAccount)) { return(orderChargeAccount); } } else { return(orderChargeAccount); } } catch (Exception) { } return(null); }
/// <summary> /// Given all relevant transaction/line info, this method builds a charge configuration header /// containing the appropriate relations to be consumed by the ChargeDataManager to find /// charge configurations in the database. /// </summary> /// <param name="accountType">The customer relation type on the header.</param> /// <param name="itemType">The item relation type on the header.</param> /// <param name="deliveryType">The delivery relation type on the header.</param> /// <param name="customerId">The account number of the customer on the header.</param> /// <param name="customerGroup">The customer charge account group on the header.</param> /// <param name="itemId">The item id.</param> /// <param name="itemGroup">The item charge group id.</param> /// <param name="deliveryMode">The delivery mode code.</param> /// <param name="deliveryModeGroup">The delivery mode charge group id.</param> /// <returns> /// Charge configuration header built from the parameters to use to query for configurations. /// </returns> private static ChargeConfigurationHeader BuildConfigurationHeader( ChargeAccountType accountType, ChargeItemType itemType, ChargeDeliveryType deliveryType, string customerId, string customerGroup, string itemId, string itemGroup, string deliveryMode, string deliveryModeGroup) { // extract appropriate account relation string string accountRelation = string.Empty; if (accountType == ChargeAccountType.Customer) { accountRelation = customerId; } else if (accountType == ChargeAccountType.CustomerGroup) { accountRelation = customerGroup; } // extract appropriate item relation string string itemRelation = string.Empty; if (itemType == ChargeItemType.Item) { itemRelation = itemId; } else if (itemType == ChargeItemType.ItemGroup) { itemRelation = itemGroup; } // extract appropriate delivery mode relation string string deliveryRelation = string.Empty; if (deliveryType == ChargeDeliveryType.DeliveryMode) { deliveryRelation = deliveryMode; } else if (deliveryType == ChargeDeliveryType.DeliveryModeGroup) { deliveryRelation = deliveryModeGroup; } var header = new ChargeConfigurationHeader { AccountType = accountType, AccountRelation = accountRelation ?? string.Empty, ItemType = itemType, ItemRelation = itemRelation ?? string.Empty, DeliveryType = deliveryType, DeliveryRelation = deliveryRelation ?? string.Empty, }; return(header); }
public static bool UpdateChargeAccountType(ChargeAccountType chargeAccountType) { try { using (DCLEntities dcl = new DCLEntities()) { dcl.Entry(chargeAccountType).State = System.Data.Entity.EntityState.Modified; return(dcl.SaveChanges() > 0); } } catch (Exception) { return(false); } }
public static bool AddChargeAccountType(ChargeAccountType chargeAccountType) { try { using (DCLEntities dcl = new DCLEntities()) { chargeAccountType = dcl.ChargeAccountType.Add(chargeAccountType); return(dcl.SaveChanges() > 0); } } catch (Exception) { return(false); } }
public static bool DeleteChargeAccountType(ChargeAccountType chargeAccountType) { try { using (DCLEntities dcl = new DCLEntities()) { dcl.ChargeAccountType.Attach(chargeAccountType); dcl.ChargeAccountType.Remove(chargeAccountType); return(dcl.SaveChanges() > 0); } } catch (Exception) { return(false); } }
void LoadType(System.Windows.Forms.ComboBox cmb, bool isCard = false, bool isQuery = false) { List <ChargeAccountType> chargeAccountTypeSet = SQLChargeAccountType.GetChargeAccountType(p => p.IsCard == isCard); if (isQuery) { ChargeAccountType type = new ChargeAccountType() { Description = "全部", ChargeAccountTypeID = 000000 }; chargeAccountTypeSet.Add(type); } cmb.DataSource = chargeAccountTypeSet; cmb.DisplayMember = "Description"; cmb.ValueMember = "ChargeAccountTypeID"; }