Пример #1
0
        /// <summary>
        /// 完成对saletmp00表的插入
        /// </summary>
        /// <returns>bool变量</returns>
        public bool DataInsertSaleTmp00()
        {
            SALETMP00 saleTmp00 = new SALETMP00();

            saleTmp00.TOT_QUAN1  = 0;
            saleTmp00.TOT_SALES1 = 0;
            return(DataInsertSales.InitDataInsertSales().insertSaleTemp00(saleTmp00));
        }
Пример #2
0
        /// <summary>
        /// 对saletmp00表的相应记录的更新
        /// </summary>
        /// <param name="tot_quan">总销售量</param>
        /// <param name="tot_sales">总销售额</param>
        /// <returns>bool变量</returns>
        public bool DataUpdateSaleTmp00(Decimal tot_quan, Decimal tot_sales)
        {
            string    datetime  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            SALETMP00 saleTmp00 = new SALETMP00();

            saleTmp00.TOT_QUAN1  = tot_quan + GetSaleTmp00.InitGetSaleTmp00(Info.shop_id, Info.sale_id).SaleTmp00TotQuan();
            saleTmp00.TOT_SALES1 = tot_sales + GetSaleTmp00.InitGetSaleTmp00(Info.shop_id, Info.sale_id).SaleTmp00TotSales();
            string sql = "UPDATE SALETMP00 SET  TOT_SALES=" + saleTmp00.TOT_SALES1 + ",TOT_QUAN=" + saleTmp00.TOT_QUAN1 + ",LAST_UPDATE='" + datetime + "'  WHERE  SHOP_ID='" + Info.shop_id + "' AND SALE_ID='" + Info.sale_id + "'";

            return(base.RunSQL(sql));
        }
        /// <summary>
        /// 往saleTemp00中插入一条记录
        /// </summary>
        /// <param name="saleTemp00">SALETMP00属性类</param>
        /// <returns>bool</returns>
        public bool insertSaleTemp00(SALETMP00 saleTemp00)
        {
            SqlParameter[] para = new SqlParameter[16];
            para[0]        = new SqlParameter("@SHOP_ID", SqlDbType.NVarChar, 12);
            para[1]        = new SqlParameter("@SALE_ID", SqlDbType.NVarChar, 32);
            para[2]        = new SqlParameter("@STATUS_ID", SqlDbType.NChar, 1);
            para[3]        = new SqlParameter("@POS_ID", SqlDbType.NVarChar, 2);
            para[4]        = new SqlParameter("@SALE_DATE", SqlDbType.DateTime);
            para[5]        = new SqlParameter("@TOT_SALES", SqlDbType.Money);
            para[6]        = new SqlParameter("@TRANSFER_STATUS", SqlDbType.NChar, 1);
            para[7]        = new SqlParameter("@LOCKED", SqlDbType.Bit);
            para[8]        = new SqlParameter("@TOT_QUAN", SqlDbType.Decimal);
            para[9]        = new SqlParameter("@CHANGE", SqlDbType.Money);
            para[10]       = new SqlParameter("@METHOD_ID", SqlDbType.Int);
            para[11]       = new SqlParameter("@TOT_TAX", SqlDbType.Money);
            para[12]       = new SqlParameter("@MEAL_KIND", SqlDbType.SmallInt);
            para[13]       = new SqlParameter("@LAST_UPDATE", SqlDbType.DateTime);
            para[14]       = new SqlParameter("@SALE_USER", SqlDbType.NVarChar, 10);
            para[15]       = new SqlParameter("@STORE_ID", SqlDbType.NVarChar, 20);
            para[0].Value  = Info.shop_id;
            para[1].Value  = Info.sale_id;
            para[2].Value  = "2";
            para[3].Value  = Info.pos_id;
            para[4].Value  = DateTime.Now;
            para[5].Value  = saleTemp00.TOT_SALES1;
            para[6].Value  = "0";
            para[7].Value  = 0;
            para[8].Value  = saleTemp00.TOT_QUAN1;
            para[9].Value  = 0;
            para[10].Value = 1;
            para[11].Value = 0;
            para[12].Value = 0;
            para[13].Value = DateTime.Now;
            para[14].Value = Info.emp_id;
            para[15].Value = Info.shop_id;
            string sql = "insert SALETMP00(SHOP_ID, SALE_ID, STATUS_ID, POS_ID, SALE_DATE, TOT_SALES, TRANSFER_STATUS, LOCKED, TOT_QUAN, CHANGE, METHOD_ID, TOT_TAX, MEAL_KIND, LAST_UPDATE, SALE_USER,STORE_ID) values(@SHOP_ID, @SALE_ID, @STATUS_ID, @POS_ID, @SALE_DATE, @TOT_SALES, @TRANSFER_STATUS, @LOCKED, @TOT_QUAN, @CHANGE, @METHOD_ID, @TOT_TAX, @MEAL_KIND, @LAST_UPDATE, @SALE_USER,@STORE_ID)";

            return(base.RunSQL(sql, para));
        }
        /// <summary>
        /// 插入单餐(插入表SALETMP01)
        /// </summary>
        /// <param name="prod_Id">商品id号</param>
        /// <param name="number">商品的数量</param>
        /// <param name="discount">折扣</param>
        /// <returns>成功插入返回true</returns>
        public bool InsertSaleTmp1(string prod_Id, int number, decimal discount)
        {
            int       count     = 0;//商品的原数量
            SALETMP00 saleTmp00 = new SALETMP00();

            saleTmp00.TOT_QUAN1 = Convert.ToDecimal(number);
            if (discount != 0)
            {
                saleTmp00.TOT_SALES1 = Info.sale_price * discount * Convert.ToDecimal(0.01);
            }
            else
            {
                saleTmp00.TOT_SALES1 = Info.sale_price;
            }
            InsertSaleTmp00.InitInsertSaleTmp00().DataUpdateSaleTmp00(saleTmp00.TOT_QUAN1, saleTmp00.TOT_SALES1);
            //首先检查是否有已点过的相同产品,则把那个产品数量加 1并返回
            try
            {
                DataSet dataSet = DataGetSaleTemp01.InitDataDataGetSaleTmp01().GetSales(Info.sale_id);

                for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                {
                    if (prod_Id == dataSet.Tables[0].Rows[i]["prod_id"].ToString() && dataSet.Tables[0].Rows[i]["COMB_TYPE"].ToString() != "2")
                    {
                        count = int.Parse(dataSet.Tables[0].Rows[i]["qty"].ToString());
                        UpdateSales updateSales = new UpdateSales();
                        updateSales.setSalesQty(prod_Id, 2, count + number);
                        return(true);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            SaleTmp01 saleTmp01 = new SaleTmp01();

            saleTmp01.Shop_id    = Info.shop_id;
            saleTmp01.Sale_id    = Info.sale_id;
            saleTmp01.Sale_sno   = Info.sale_sno;
            saleTmp01.Prod_id    = prod_Id;
            saleTmp01.Sale_price = Info.sale_price;

            saleTmp01.Qty = number;
            if (discount != 0)
            {
                try
                {
                    saleTmp01.Item_disc = (Info.sale_price * discount * Convert.ToDecimal(0.01) - Info.sale_price) * number;
                }

                catch { saleTmp01.Item_disc = 0; }
            }
            else
            {
                saleTmp01.Item_disc = 0;
            }
            saleTmp01.Prom_id    = "0";
            saleTmp01.Prom_sno   = 0;
            saleTmp01.Price_type = "0";

            // saleTmp01.Free_emp = Info.emp_id;
            saleTmp01.Comb_sale_sno = 0;
            saleTmp01.Comb_sno      = 0;
            saleTmp01.Comb_type     = "0 ";

            saleTmp01.Item_tax    = 0;
            saleTmp01.Outincome   = false;
            saleTmp01.Meal_ticket = 0;
            saleTmp01.By_token    = false;
            saleTmp01.Relate_prod = prod_Id;

            saleTmp01.Sale_orginal_price = Info.sale_price;
            saleTmp01.Item_disc_tot      = 0;
            saleTmp01.Act_price          = saleTmp01.Sale_price;
            saleTmp01.Isprom             = false;
            saleTmp01.Group_prod         = prod_Id;
            saleTmp01.Transfer_status    = "0";
            saleTmp01.Status_id          = "2";
            try
            {
                return(DataInsertSaleTmp01.InitDataInsertSale01().InsertSale01(saleTmp01));
            }
            catch (Exception ex)
            {
                throw ex;
                //return false;
            }
        }