Пример #1
0
        public static string GetInsertCreditHistory(int customerRemainingCredit, int customers_id, int?abo_type, int quantity)
        {
            int?credit_free;
            int?quantity_free = 0;
            int?credit_paid   = 0;
            int?quantity_paid = 0;
            DVdPostMobileApIWS contextBeProd = null;


            string connstr_prod = ConfigurationManager.ConnectionStrings["prod-WRITE"].ConnectionString;

            InsertMobileApplicationLog(customers_id, "GetInsertCreditHistory customerRemainingCredit, quantity 1: " + connstr_prod, customerRemainingCredit.ToString() + quantity.ToString(), "", -1);
            contextBeProd = new DVdPostMobileApIWS(new MySqlConnection(connstr_prod));

            string sqlmax = QueriesDB.getSelectMaxIDCreditHistory(customers_id);
            IEnumerable <numberresult> res = contextBeProd.ExecuteQuery <numberresult>(sqlmax);
            numberresult max   = res.FirstOrDefault <numberresult>();
            int          maxID = max.r;

            var x = from creditHistory in contextBeProd.CreditHistory
                    where creditHistory.ID == maxID
                    select creditHistory;
            CreditHistory ch = x.SingleOrDefault();

            if (ch == null)
            {
                credit_free = 0;
                credit_paid = 0;
            }
            else
            {
                credit_free = ch.CreditFree + ch.QuantityFree;
                credit_paid = ch.CreditPaid + ch.QuantityPaid;
            }

            InsertMobileApplicationLog(customers_id, "GetInsertCreditHistory credit_free, credit_paid, ch.ID, ch.CreditPaid, ch.QuantityPaid, ch.CreditFree, ch.QuantityFree, 2: ", credit_free.ToString() + ", " + credit_paid.ToString() + ", " + ch.ID.ToString() + ", " + ch.CreditPaid.ToString() + ", " + ch.QuantityPaid.ToString() + ", " + ch.CreditFree.ToString() + ", " + ch.QuantityFree.ToString(), "", -1);

            if (credit_free >= quantity)
            {
                quantity_free = quantity;
                quantity_paid = 0;
            }
            else if (credit_free + customerRemainingCredit >= quantity)
            {
                quantity_paid = quantity - credit_free;
                quantity_free = credit_free;
            }
            else if (customerRemainingCredit >= quantity)
            {
                quantity_free = 0;
                quantity_paid = quantity;
            }

            string sql = string.Format("insert into credit_history (customers_id , credit_action_id , user_modified,credit_paid , quantity_paid ,  quantity_free , credit_free , orders_id,abo_type )" +
                                       " values ({0}, 12, 77, {1}, {2}, {3}, {4}, null, {5} )", customers_id, credit_paid, (-1) * quantity_paid, (-1) * quantity_free, credit_free, abo_type);

            return(sql);
        }
Пример #2
0
        //public class CreditHistory
        //{
        //    public int credit  { get; set; }
        //    public int quantity_free  { get; set; }
        //    public int quantity_paid  { get; set; }
        //    public int credit_free  { get; set; }
        //    public int credit_paid { get; set; }
        //}

        public static void InsertMobileLog(int cn, string method, string parameters, int device, DVdPostMobileApIWS context)
        {
            try
            {
                string sql = QueriesDB.getInsertMobileLog(cn, method, parameters, device);
                context.ExecuteCommand(sql);
            }
            catch
            {
            }
        }
Пример #3
0
 public static void InsertMobileLog(int cn, string method, string parameters, int device)
 {
     try
     {
         string             connstr      = ConfigurationManager.ConnectionStrings["mobileapiws"].ConnectionString;
         DVdPostMobileApIWS modelcontext = new DVdPostMobileApIWS(new MySqlConnection(connstr));
         string             sql          = QueriesDB.getInsertMobileLog(cn, method, parameters, device);
         modelcontext.ExecuteCommand(sql);
     }
     catch
     {
     }
 }
Пример #4
0
        //public class CreditHistory
        //{
        //    public int credit  { get; set; }
        //    public int quantity_free  { get; set; }
        //    public int quantity_paid  { get; set; }
        //    public int credit_free  { get; set; }
        //    public int credit_paid { get; set; }
        //}

        public static void InsertMobileLog(int cn, string method, string parameters, int device, DVdPostMobileApIWS context)
        {
            string sql = string.Empty;

            try
            {
                sql = QueriesDB.getInsertMobileLog(cn, method, parameters, device);
                context.ExecuteCommand(sql);
            }
            catch (Exception e)
            {
                System.Diagnostics.EventLog hosteventLog = new System.Diagnostics.EventLog();
                ((System.ComponentModel.ISupportInitialize)(hosteventLog)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(hosteventLog)).EndInit();
                hosteventLog.Source = "PlushHTTPSServiceSource";
                hosteventLog.Log    = "PlushHTTPSServiceLog";
                hosteventLog.WriteEntry("InsertMobileLog cn, method, parameters, sql: " + cn + ", " + method + ", " + parameters + ", " + sql + ", error: " + e.Message, System.Diagnostics.EventLogEntryType.Error);
            }
        }