예제 #1
0
 private void ShowInfo(long id)
 {
     Jium.BLL.piorecord   bll   = new Jium.BLL.piorecord();
     Jium.Model.piorecord model = bll.GetModel(id);
     this.lblid.Text         = model.id.ToString();
     this.txtptime.Text      = model.ptime;
     this.txtpcode.Text      = model.pcode;
     this.txtpcnt.Text       = model.pcnt.ToString();
     this.txtpsaleprice.Text = model.psaleprice.ToString();
     this.txtprealprice.Text = model.prealprice.ToString();
     //this.txtptype.Text=model.ptype.ToString();
     this.dropptype.SelectedValue = model.ptype.ToString();
     this.txtpzekou.Text          = model.pzekou.ToString();
     this.txtpremark.Text         = model.premark;
     this.txtpguestid.Text        = model.pguestid.ToString();
     this.txtpsalerid.Text        = model.psalerid.ToString();
     this.txtpios1.Text           = model.pios1;
     this.txtpios2.Text           = model.pios2;
     //this.txtpios3.Text=model.pios3;
     //this.txtpios4.Text=model.pios4;
     //this.txtpios5.Text=model.pios5;
     //this.txtpiod1.Text=model.piod1.ToString();
     //this.txtpiod2.Text=model.piod2.ToString();
     //this.txtpiod3.Text=model.piod3.ToString();
     //this.txtpiod5.Text=model.piod5.ToString();
     //this.txtpiod4.Text=model.piod4.ToString();
     //this.txtpiodc1.Text=model.piodc1.ToString();
     //this.txtpiodc2.Text=model.piodc2.ToString();
     //this.txtpiodc3.Text=model.piodc3.ToString();
     //this.txtpiodc4.Text=model.piodc4.ToString();
     //this.txtpiodc5.Text=model.piodc5.ToString();
 }
예제 #2
0
        protected void btnPlibAdd_Click(object sender, EventArgs e)
        {
            var btn   = (Button)sender;
            var index = ((GridViewRow)btn.Parent.Parent).RowIndex;
            var sNum  = gridViewLib.Rows[index].Cells[5].Text;

            var lst = new List <Jium.Model.piorecord>();

            //#warning 代码生成警告:请检查确认Cells的列索引是否正确
            if (gridViewLib.DataKeys[index].Value != null)
            {
                var model = new Jium.Model.piorecord();
                model.pcode  = gridViewLib.Rows[index].Cells[1].Text; // i.ToString();
                model.pios3  = gridViewLib.Rows[index].Cells[2].Text; // gridViewLib.Rows[i].Cells[3].ToString();
                model.pzekou = 1;
                model.pcnt   = 1;
                model.piod1  = 0;
                string where = string.Format("pcode='{0}'", model.pcode);
                var productBll = new Jium.BLL.product();
                var lstProduct = productBll.GetModelList(where);
                if (lstProduct.Count > 0)
                {
                    model.psaleprice = lstProduct.FirstOrDefault().psaleprice;
                    model.piod1      = lstProduct.FirstOrDefault().pd1;
                    model.pios4      = lstProduct.FirstOrDefault().ps1;
                }
                lst.Add(model);
            }

            for (int i = 0; i < gridViewBuy.Rows.Count; i++)
            {
                var model = new Jium.Model.piorecord();
                model.pcode      = gridViewBuy.Rows[i].Cells[0].Text;
                model.pios3      = gridViewBuy.Rows[i].Cells[1].Text;
                model.psaleprice = decimal.Parse(gridViewBuy.Rows[i].Cells[3].Text);
                model.pcnt       = int.Parse(gridViewBuy.Rows[i].Cells[5].Text);
                model.pzekou     = decimal.Parse(gridViewBuy.Rows[i].Cells[6].Text);
                lst.Add(model);
            }

            gridViewBuy.DataSource = lst;
            var sumTotal = lst.Sum(e1 => e1.pcnt * e1.psaleprice);
            var sumReal  = lst.Sum(e1 => e1.pcnt * e1.psaleprice * e1.pzekou);
            var zekou    = sumTotal == 0 ? 1 : sumReal / sumTotal;

            txtSumTotal.Text = sumTotal.ToString();
            txtSumReal.Text  = sumReal.ToString();
            txtZekou.Text    = zekou.ToString();


            gridViewBuy.DataBind();
        }
예제 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Jium.Model.piorecord GetModel(long id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,ptime,pcode,pcnt,psaleprice,prealprice,ptype,pzekou,premark,pguestid,psalerid,pios1,pios2,pios3,pios4,pios5,piod1,piod2,piod3,piod5,piod4,piodc1,piodc2,piodc3,piodc4,piodc5 from piorecord ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int64)
            };
            parameters[0].Value = id;

            Jium.Model.piorecord model = new Jium.Model.piorecord();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            //if(this.txtptime.Text.Trim().Length==0)
            //{
            //	strErr+="ptime不能为空!\\n";
            //}
            if (this.txtpcode.Text.Trim().Length == 0)
            {
                strErr += "pcode不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtpcnt.Text))
            {
                strErr += "pcnt格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtpsaleprice.Text) && !PageValidate.IsDecimal(txtpsaleprice.Text))
            {
                strErr += "psaleprice格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtprealprice.Text) && !PageValidate.IsDecimal(txtprealprice.Text))
            {
                strErr += "prealprice格式错误!\\n";
            }
            if (!PageValidate.IsNumber(/*txtptype.Text*/ dropptype.SelectedValue))
            {
                strErr += "ptype格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtpzekou.Text) && !PageValidate.IsDecimal(txtpzekou.Text))
            {
                strErr += "pzekou格式错误!\\n";
            }
            //if(this.txtpremark.Text.Trim().Length==0)
            //{
            //	strErr+="premark不能为空!\\n";
            //}
            if (!PageValidate.IsNumber(txtpguestid.Text))
            {
                strErr += "pguestid格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtpsalerid.Text))
            {
                strErr += "psalerid格式错误!\\n";
            }

            if (this.txtpios1.Text.Trim().Length == 0)
            {
                strErr += "pios1不能为空!\\n";
            }
            if (this.txtpios2.Text.Trim().Length == 0)
            {
                strErr += "pios2不能为空!\\n";
            }

            /*
             * if(this.txtpios3.Text.Trim().Length==0)
             * {
             * strErr+="pios3不能为空!\\n";
             * }
             * if(this.txtpios4.Text.Trim().Length==0)
             * {
             * strErr+="pios4不能为空!\\n";
             * }
             * if(this.txtpios5.Text.Trim().Length==0)
             * {
             * strErr+="pios5不能为空!\\n";
             * }
             * if(!PageValidate.IsNumber(txtpiod1.Text))
             * {
             * strErr+="piod1格式错误!\\n";
             * }
             * if(!PageValidate.IsNumber(txtpiod2.Text))
             * {
             * strErr+="piod2格式错误!\\n";
             * }
             * if(!PageValidate.IsNumber(txtpiod3.Text))
             * {
             * strErr+="piod3格式错误!\\n";
             * }
             * if(!PageValidate.IsNumber(txtpiod5.Text))
             * {
             * strErr+="piod5格式错误!\\n";
             * }
             * if(!PageValidate.IsNumber(txtpiod4.Text))
             * {
             * strErr+="piod4格式错误!\\n";
             * }
             * if(!PageValidate.IsDecimal(txtpiodc1.Text))
             * {
             * strErr+="piodc1格式错误!\\n";
             * }
             * if(!PageValidate.IsDecimal(txtpiodc2.Text))
             * {
             * strErr+="piodc2格式错误!\\n";
             * }
             * if(!PageValidate.IsDecimal(txtpiodc3.Text))
             * {
             * strErr+="piodc3格式错误!\\n";
             * }
             * if(!PageValidate.IsDecimal(txtpiodc4.Text))
             * {
             * strErr+="piodc4格式错误!\\n";
             * }
             * if(!PageValidate.IsDecimal(txtpiodc5.Text))
             * {
             * strErr+="piodc5格式错误!\\n";
             * }
             */

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            long    id         = long.Parse(this.lblid.Text);
            string  ptime      = DateTime.Now.ToString("yyyyMMddHHmmss");
            string  pcode      = this.txtpcode.Text;
            int     pcnt       = int.Parse(this.txtpcnt.Text);
            decimal psaleprice = decimal.Parse(this.txtpsaleprice.Text);
            decimal prealprice = decimal.Parse(this.txtprealprice.Text);
            int     ptype      = int.Parse(/*txtptype.Text*/ dropptype.SelectedValue);
            decimal pzekou     = decimal.Parse(this.txtpzekou.Text);
            string  premark    = this.txtpremark.Text;
            int     pguestid   = int.Parse(this.txtpguestid.Text);
            int     psalerid   = int.Parse(this.txtpsalerid.Text);
            string  pios1      = this.txtpios1.Text;
            string  pios2      = this.txtpios2.Text;

            //string pios3=this.txtpios3.Text;
            //string pios4=this.txtpios4.Text;
            //string pios5=this.txtpios5.Text;
            //int piod1=int.Parse(this.txtpiod1.Text);
            //int piod2=int.Parse(this.txtpiod2.Text);
            //int piod3=int.Parse(this.txtpiod3.Text);
            //int piod5=int.Parse(this.txtpiod5.Text);
            //int piod4=int.Parse(this.txtpiod4.Text);
            //decimal piodc1=decimal.Parse(this.txtpiodc1.Text);
            //decimal piodc2=decimal.Parse(this.txtpiodc2.Text);
            //decimal piodc3=decimal.Parse(this.txtpiodc3.Text);
            //decimal piodc4=decimal.Parse(this.txtpiodc4.Text);
            //decimal piodc5=decimal.Parse(this.txtpiodc5.Text);


            Jium.Model.piorecord model = new Jium.Model.piorecord();
            model.id         = id;
            model.ptime      = ptime;
            model.pcode      = pcode;
            model.pcnt       = pcnt;
            model.psaleprice = psaleprice;
            model.prealprice = prealprice;
            model.ptype      = ptype;
            model.pzekou     = pzekou;
            model.premark    = premark;
            model.pguestid   = pguestid;
            model.psalerid   = psalerid;
            model.pios1      = pios1;
            model.pios2      = pios2;
            //model.pios3=pios3;
            //model.pios4=pios4;
            //model.pios5=pios5;
            //model.piod1=piod1;
            //model.piod2=piod2;
            //model.piod3=piod3;
            //model.piod5=piod5;
            //model.piod4=piod4;
            //model.piodc1=piodc1;
            //model.piodc2=piodc2;
            //model.piodc3=piodc3;
            //model.piodc4=piodc4;
            //model.piodc5=piodc5;

            Jium.BLL.piorecord bll = new Jium.BLL.piorecord();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
예제 #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Jium.Model.piorecord model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into piorecord(");
            strSql.Append("ptime,pcode,pcnt,psaleprice,prealprice,ptype,pzekou,premark,pguestid,psalerid,pios1,pios2,pios3,pios4,pios5,piod1,piod2,piod3,piod5,piod4,piodc1,piodc2,piodc3,piodc4,piodc5)");
            strSql.Append(" values (");
            strSql.Append("@ptime,@pcode,@pcnt,@psaleprice,@prealprice,@ptype,@pzekou,@premark,@pguestid,@psalerid,@pios1,@pios2,@pios3,@pios4,@pios5,@piod1,@piod2,@piod3,@piod5,@piod4,@piodc1,@piodc2,@piodc3,@piodc4,@piodc5)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ptime",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pcode",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pcnt",       MySqlDbType.Int32,    11),
                new MySqlParameter("@psaleprice", MySqlDbType.Decimal,  20),
                new MySqlParameter("@prealprice", MySqlDbType.Decimal,  20),
                new MySqlParameter("@ptype",      MySqlDbType.Int32,    11),
                new MySqlParameter("@pzekou",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@premark",    MySqlDbType.VarChar, 200),
                new MySqlParameter("@pguestid",   MySqlDbType.Int32,    11),
                new MySqlParameter("@psalerid",   MySqlDbType.Int32,    11),
                new MySqlParameter("@pios1",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pios2",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pios3",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pios4",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pios5",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@piod1",      MySqlDbType.Int32,    11),
                new MySqlParameter("@piod2",      MySqlDbType.Int32,    11),
                new MySqlParameter("@piod3",      MySqlDbType.Int32,    11),
                new MySqlParameter("@piod5",      MySqlDbType.Int32,    11),
                new MySqlParameter("@piod4",      MySqlDbType.Int32,    11),
                new MySqlParameter("@piodc1",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@piodc2",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@piodc3",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@piodc4",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@piodc5",     MySqlDbType.Decimal, 20)
            };
            parameters[0].Value  = model.ptime;
            parameters[1].Value  = model.pcode;
            parameters[2].Value  = model.pcnt;
            parameters[3].Value  = model.psaleprice;
            parameters[4].Value  = model.prealprice;
            parameters[5].Value  = model.ptype;
            parameters[6].Value  = model.pzekou;
            parameters[7].Value  = model.premark;
            parameters[8].Value  = model.pguestid;
            parameters[9].Value  = model.psalerid;
            parameters[10].Value = model.pios1;
            parameters[11].Value = model.pios2;
            parameters[12].Value = model.pios3;
            parameters[13].Value = model.pios4;
            parameters[14].Value = model.pios5;
            parameters[15].Value = model.piod1;
            parameters[16].Value = model.piod2;
            parameters[17].Value = model.piod3;
            parameters[18].Value = model.piod5;
            parameters[19].Value = model.piod4;
            parameters[20].Value = model.piodc1;
            parameters[21].Value = model.piodc2;
            parameters[22].Value = model.piodc3;
            parameters[23].Value = model.piodc4;
            parameters[24].Value = model.piodc5;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Jium.Model.piorecord DataRowToModel(DataRow row)
 {
     Jium.Model.piorecord model = new Jium.Model.piorecord();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = long.Parse(row["id"].ToString());
         }
         if (row["ptime"] != null)
         {
             model.ptime = row["ptime"].ToString();
         }
         if (row["pcode"] != null)
         {
             model.pcode = row["pcode"].ToString();
         }
         if (row["pcnt"] != null && row["pcnt"].ToString() != "")
         {
             model.pcnt = int.Parse(row["pcnt"].ToString());
         }
         if (row["psaleprice"] != null && row["psaleprice"].ToString() != "")
         {
             model.psaleprice = decimal.Parse(row["psaleprice"].ToString());
         }
         if (row["prealprice"] != null && row["prealprice"].ToString() != "")
         {
             model.prealprice = decimal.Parse(row["prealprice"].ToString());
         }
         if (row["ptype"] != null && row["ptype"].ToString() != "")
         {
             model.ptype = int.Parse(row["ptype"].ToString());
         }
         if (row["pzekou"] != null && row["pzekou"].ToString() != "")
         {
             model.pzekou = decimal.Parse(row["pzekou"].ToString());
         }
         if (row["premark"] != null)
         {
             model.premark = row["premark"].ToString();
         }
         if (row["pguestid"] != null && row["pguestid"].ToString() != "")
         {
             model.pguestid = int.Parse(row["pguestid"].ToString());
         }
         if (row["psalerid"] != null && row["psalerid"].ToString() != "")
         {
             model.psalerid = int.Parse(row["psalerid"].ToString());
         }
         if (row["pios1"] != null)
         {
             model.pios1 = row["pios1"].ToString();
         }
         if (row["pios2"] != null)
         {
             model.pios2 = row["pios2"].ToString();
         }
         if (row["pios3"] != null)
         {
             model.pios3 = row["pios3"].ToString();
         }
         if (row["pios4"] != null)
         {
             model.pios4 = row["pios4"].ToString();
         }
         if (row["pios5"] != null)
         {
             model.pios5 = row["pios5"].ToString();
         }
         if (row["piod1"] != null && row["piod1"].ToString() != "")
         {
             model.piod1 = int.Parse(row["piod1"].ToString());
         }
         if (row["piod2"] != null && row["piod2"].ToString() != "")
         {
             model.piod2 = int.Parse(row["piod2"].ToString());
         }
         if (row["piod3"] != null && row["piod3"].ToString() != "")
         {
             model.piod3 = int.Parse(row["piod3"].ToString());
         }
         if (row["piod5"] != null && row["piod5"].ToString() != "")
         {
             model.piod5 = int.Parse(row["piod5"].ToString());
         }
         if (row["piod4"] != null && row["piod4"].ToString() != "")
         {
             model.piod4 = int.Parse(row["piod4"].ToString());
         }
         if (row["piodc1"] != null && row["piodc1"].ToString() != "")
         {
             model.piodc1 = decimal.Parse(row["piodc1"].ToString());
         }
         if (row["piodc2"] != null && row["piodc2"].ToString() != "")
         {
             model.piodc2 = decimal.Parse(row["piodc2"].ToString());
         }
         if (row["piodc3"] != null && row["piodc3"].ToString() != "")
         {
             model.piodc3 = decimal.Parse(row["piodc3"].ToString());
         }
         if (row["piodc4"] != null && row["piodc4"].ToString() != "")
         {
             model.piodc4 = decimal.Parse(row["piodc4"].ToString());
         }
         if (row["piodc5"] != null && row["piodc5"].ToString() != "")
         {
             model.piodc5 = decimal.Parse(row["piodc5"].ToString());
         }
     }
     return(model);
 }
예제 #7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Jium.Model.piorecord model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update piorecord set ");
            strSql.Append("ptime=@ptime,");
            strSql.Append("pcode=@pcode,");
            strSql.Append("pcnt=@pcnt,");
            strSql.Append("psaleprice=@psaleprice,");
            strSql.Append("prealprice=@prealprice,");
            strSql.Append("ptype=@ptype,");
            strSql.Append("pzekou=@pzekou,");
            strSql.Append("premark=@premark,");
            strSql.Append("pguestid=@pguestid,");
            strSql.Append("psalerid=@psalerid,");
            strSql.Append("pios1=@pios1,");
            strSql.Append("pios2=@pios2,");
            strSql.Append("pios3=@pios3,");
            strSql.Append("pios4=@pios4,");
            strSql.Append("pios5=@pios5,");
            strSql.Append("piod1=@piod1,");
            strSql.Append("piod2=@piod2,");
            strSql.Append("piod3=@piod3,");
            strSql.Append("piod5=@piod5,");
            strSql.Append("piod4=@piod4,");
            strSql.Append("piodc1=@piodc1,");
            strSql.Append("piodc2=@piodc2,");
            strSql.Append("piodc3=@piodc3,");
            strSql.Append("piodc4=@piodc4,");
            strSql.Append("piodc5=@piodc5");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ptime",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pcode",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pcnt",       MySqlDbType.Int32,    11),
                new MySqlParameter("@psaleprice", MySqlDbType.Decimal,  20),
                new MySqlParameter("@prealprice", MySqlDbType.Decimal,  20),
                new MySqlParameter("@ptype",      MySqlDbType.Int32,    11),
                new MySqlParameter("@pzekou",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@premark",    MySqlDbType.VarChar, 200),
                new MySqlParameter("@pguestid",   MySqlDbType.Int32,    11),
                new MySqlParameter("@psalerid",   MySqlDbType.Int32,    11),
                new MySqlParameter("@pios1",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pios2",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pios3",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pios4",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@pios5",      MySqlDbType.VarChar,  20),
                new MySqlParameter("@piod1",      MySqlDbType.Int32,    11),
                new MySqlParameter("@piod2",      MySqlDbType.Int32,    11),
                new MySqlParameter("@piod3",      MySqlDbType.Int32,    11),
                new MySqlParameter("@piod5",      MySqlDbType.Int32,    11),
                new MySqlParameter("@piod4",      MySqlDbType.Int32,    11),
                new MySqlParameter("@piodc1",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@piodc2",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@piodc3",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@piodc4",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@piodc5",     MySqlDbType.Decimal,  20),
                new MySqlParameter("@id",         MySqlDbType.Int64, 20)
            };
            parameters[0].Value  = model.ptime;
            parameters[1].Value  = model.pcode;
            parameters[2].Value  = model.pcnt;
            parameters[3].Value  = model.psaleprice;
            parameters[4].Value  = model.prealprice;
            parameters[5].Value  = model.ptype;
            parameters[6].Value  = model.pzekou;
            parameters[7].Value  = model.premark;
            parameters[8].Value  = model.pguestid;
            parameters[9].Value  = model.psalerid;
            parameters[10].Value = model.pios1;
            parameters[11].Value = model.pios2;
            parameters[12].Value = model.pios3;
            parameters[13].Value = model.pios4;
            parameters[14].Value = model.pios5;
            parameters[15].Value = model.piod1;
            parameters[16].Value = model.piod2;
            parameters[17].Value = model.piod3;
            parameters[18].Value = model.piod5;
            parameters[19].Value = model.piod4;
            parameters[20].Value = model.piodc1;
            parameters[21].Value = model.piodc2;
            parameters[22].Value = model.piodc3;
            parameters[23].Value = model.piodc4;
            parameters[24].Value = model.piodc5;
            parameters[25].Value = model.id;

            int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #8
0
        private string GetSelIDlist()
        {
            var    lst        = new List <Jium.Model.piorecord>();
            string idlist     = "";
            bool   BxsChkd    = false;
            var    productBll = new Jium.BLL.product();

            for (int i = 0; i < gridViewLib.Rows.Count; i++)
            {
                CheckBox ChkBxItem = (CheckBox)gridViewLib.Rows[i].FindControl("SaleThis");
                if (ChkBxItem != null && ChkBxItem.Checked)
                {
                    BxsChkd = true;
                    //#warning 代码生成警告:请检查确认Cells的列索引是否正确
                    if (gridViewLib.DataKeys[i].Value != null)
                    {
                        var model = new Jium.Model.piorecord();
                        model.pcode  = gridViewLib.Rows[i].Cells[1].Text; // i.ToString();
                        model.pios3  = gridViewLib.Rows[i].Cells[2].Text; // gridViewLib.Rows[i].Cells[3].ToString();
                        model.pzekou = 1;
                        model.pcnt   = 1;
                        string where = string.Format("pcode='{0}'", model.pcode);
                        var lstProduct = productBll.GetModelList(where);
                        if (lstProduct.Count > 0)
                        {
                            model.psaleprice = lstProduct.FirstOrDefault().psaleprice;
                        }
                        lst.Add(model);
                        idlist += gridViewLib.DataKeys[i].Value.ToString() + ",";
                    }
                }
            }
            if (BxsChkd)
            {
                idlist = idlist.Substring(0, idlist.LastIndexOf(","));
            }

            decimal sum = 0;

            for (int i = 0; i < gridViewBuy.Rows.Count; i++)
            {
                var model = new Jium.Model.piorecord();
                model.pcode      = gridViewBuy.Rows[i].Cells[0].Text;
                model.pios3      = gridViewBuy.Rows[i].Cells[1].Text;
                model.psaleprice = decimal.Parse(gridViewBuy.Rows[i].Cells[2].Text);
                model.pcnt       = int.Parse(gridViewBuy.Rows[i].Cells[3].Text);
                model.pzekou     = decimal.Parse(gridViewBuy.Rows[i].Cells[4].Text);
                lst.Add(model);
            }
            //if (gridViewBuy.DataSource == null)
            //{
            gridViewBuy.DataSource = lst;
            var sumTotal = lst.Sum(e => e.pcnt * e.psaleprice);
            var sumReal  = lst.Sum(e => e.pcnt * e.psaleprice * e.pzekou);
            var zekou    = sumTotal == 0 ? 1 : sumReal / sumTotal;

            //}
            //else
            //{
            //    var lstBuy = (List<Jium.Model.piorecord>)gridViewBuy.DataSource;
            //    lstBuy.AddRange(lst);
            //    gridViewBuy.DataSource = lstBuy;
            //    sum = lstBuy.Sum(e => e.pcnt * e.psaleprice);
            //}
            txtSumTotal.Text = sumTotal.ToString();
            txtSumReal.Text  = sumReal.ToString();
            txtZekou.Text    = zekou.ToString();


            gridViewBuy.DataBind();
            return(idlist);
        }
예제 #9
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                var bres = true;
                do
                {
                    string strErr = "";
                    //if(this.txtptime.Text.Trim().Length==0)
                    //{
                    //	strErr+="ptime不能为空!\\n";
                    //}
                    if (this.txtpcode.Text.Trim().Length == 0)
                    {
                        strErr += "pcode不能为空!\\n";
                    }
                    if (!PageValidate.IsNumber(txtpcnt.Text))
                    {
                        strErr += "pcnt格式错误!\\n";
                    }
                    if (!PageValidate.IsNumber(txtpsaleprice.Text) && !PageValidate.IsDecimal(txtpsaleprice.Text))
                    {
                        strErr += "psaleprice格式错误!\\n";
                    }
                    if (!PageValidate.IsNumber(txtprealprice.Text) && !PageValidate.IsDecimal(txtprealprice.Text))
                    {
                        strErr += "prealprice格式错误!\\n";
                    }
                    if (!PageValidate.IsNumber(/*txtptype.Text*/ dropptype.SelectedValue))
                    {
                        strErr += "ptype格式错误!\\n";
                    }
                    if (!PageValidate.IsNumber(txtpzekou.Text) && !PageValidate.IsDecimal(txtpzekou.Text))
                    {
                        strErr += "pzekou格式错误!\\n";
                    }
                    //if(this.txtpremark.Text.Trim().Length==0)
                    //{
                    //	strErr+="premark不能为空!\\n";
                    //}
                    if (!PageValidate.IsNumber(txtpguestid.Text))
                    {
                        strErr += "pguestid格式错误!\\n";
                    }
                    if (!PageValidate.IsNumber(txtpsalerid.Text))
                    {
                        strErr += "psalerid格式错误!\\n";
                    }

                    if (this.txtpios1.Text.Trim().Length == 0)
                    {
                        strErr += "pios1不能为空!\\n";
                    }
                    if (this.txtpios2.Text.Trim().Length == 0)
                    {
                        strErr += "pios2不能为空!\\n";
                    }

                    //if(this.txtpios3.Text.Trim().Length==0)
                    //{
                    //    strErr+="pios3不能为空!\\n";
                    //}

                    /*
                     * if(this.txtpios4.Text.Trim().Length==0)
                     * {
                     *  strErr+="pios4不能为空!\\n";
                     * }
                     * if(this.txtpios5.Text.Trim().Length==0)
                     * {
                     *  strErr+="pios5不能为空!\\n";
                     * }
                     * if(!PageValidate.IsNumber(txtpiod1.Text))
                     * {
                     *  strErr+="piod1格式错误!\\n";
                     * }
                     * if(!PageValidate.IsNumber(txtpiod2.Text))
                     * {
                     *  strErr+="piod2格式错误!\\n";
                     * }
                     * if(!PageValidate.IsNumber(txtpiod3.Text))
                     * {
                     *  strErr+="piod3格式错误!\\n";
                     * }
                     * if(!PageValidate.IsNumber(txtpiod5.Text))
                     * {
                     *  strErr+="piod5格式错误!\\n";
                     * }
                     * if(!PageValidate.IsNumber(txtpiod4.Text))
                     * {
                     *  strErr+="piod4格式错误!\\n";
                     * }
                     * if(!PageValidate.IsDecimal(txtpiodc1.Text))
                     * {
                     *  strErr+="piodc1格式错误!\\n";
                     * }
                     * if(!PageValidate.IsDecimal(txtpiodc2.Text))
                     * {
                     *  strErr+="piodc2格式错误!\\n";
                     * }
                     * if(!PageValidate.IsDecimal(txtpiodc3.Text))
                     * {
                     *  strErr+="piodc3格式错误!\\n";
                     * }
                     * if(!PageValidate.IsDecimal(txtpiodc4.Text))
                     * {
                     *  strErr+="piodc4格式错误!\\n";
                     * }
                     * if(!PageValidate.IsDecimal(txtpiodc5.Text))
                     * {
                     *  strErr+="piodc5格式错误!\\n";
                     * }
                     */

                    if (strErr != "")
                    {
                        MessageBox.Show(this, strErr);
                        return;
                    }
                    string  ptime      = DateTime.Now.ToString("yyyyMMddHHmmss");// ,this.txtptime.Text;
                    string  pcode      = this.txtpcode.Text;
                    int     pcnt       = int.Parse(this.txtpcnt.Text);
                    decimal psaleprice = decimal.Parse(this.txtpsaleprice.Text);
                    decimal prealprice = decimal.Parse(this.txtprealprice.Text);
                    int     ptype      = int.Parse(/*txtptype.Text*/ dropptype.SelectedValue);
                    decimal pzekou     = decimal.Parse(this.txtpzekou.Text);
                    string  premark    = this.txtpremark.Text;
                    int     pguestid   = int.Parse(this.txtpguestid.Text);
                    int     psalerid   = int.Parse(this.txtpsalerid.Text);
                    string  pios1      = this.txtpios1.Text;
                    string  pios2      = this.txtpios2.Text;
                    string  pios3      = this.txtpios3.Text;
                    //string pios4=this.txtpios4.Text;
                    //string pios5=this.txtpios5.Text;
                    //int piod1=int.Parse(this.txtpiod1.Text);
                    //int piod2=int.Parse(this.txtpiod2.Text);
                    //int piod3=int.Parse(this.txtpiod3.Text);
                    //int piod5=int.Parse(this.txtpiod5.Text);
                    //int piod4=int.Parse(this.txtpiod4.Text);
                    //decimal piodc1=decimal.Parse(this.txtpiodc1.Text);
                    //decimal piodc2=decimal.Parse(this.txtpiodc2.Text);
                    //decimal piodc3=decimal.Parse(this.txtpiodc3.Text);
                    //decimal piodc4=decimal.Parse(this.txtpiodc4.Text);
                    //decimal piodc5=decimal.Parse(this.txtpiodc5.Text);

                    Jium.Model.piorecord model = new Jium.Model.piorecord();
                    model.ptime      = ptime;
                    model.pcode      = pcode;
                    model.pcnt       = pcnt;
                    model.psaleprice = psaleprice;
                    model.prealprice = prealprice;
                    model.ptype      = ptype;
                    model.pzekou     = pzekou;
                    model.premark    = premark;
                    model.pguestid   = pguestid;
                    model.psalerid   = psalerid;
                    model.pios1      = pios1;
                    model.pios2      = pios2;
                    model.pios3      = pios3;
                    //model.pios4=pios4;
                    //model.pios5=pios5;
                    //model.piod1=piod1;
                    //model.piod2=piod2;
                    //model.piod3=piod3;
                    //model.piod5=piod5;
                    //model.piod4=piod4;
                    //model.piodc1=piodc1;
                    //model.piodc2=piodc2;
                    //model.piodc3=piodc3;
                    //model.piodc4=piodc4;
                    //model.piodc5=piodc5;

                    Jium.BLL.product bllProduct = new Jium.BLL.product();
                    Jium.BLL.plib    bllPlib    = new Jium.BLL.plib();
                    var where = string.Format("pcode='{0}'", pcode);
                    if (bllProduct.GetRecordCount(where) == 0)
                    {
                        if (this.txtpios3.Text.Trim().Length == 0)
                        {
                            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "新品请输入货品名称!", "add.aspx");
                            return;
                        }

                        Jium.Model.product pmodel = new Jium.Model.product();
                        pmodel.pcode      = model.pcode;
                        pmodel.pname      = model.pios3;
                        pmodel.pdesc      = model.premark;
                        pmodel.psaleprice = model.psaleprice;
                        pmodel.prealprice = model.prealprice;
                        pmodel.ptype      = "-";
                        pmodel.pisgroup   = 0;
                        bllProduct.Add(pmodel);
                    }


                    Jium.BLL.piorecord bll = new Jium.BLL.piorecord();
                    if (!bll.Add(model))
                    {
                        break;
                    }
                    var pllst = bllPlib.GetModelList(where);
                    if (pllst.Count == 0)
                    {
                        Jium.Model.plib plmodel = new Jium.Model.plib();
                        plmodel.pcode        = model.pcode;
                        plmodel.pname        = model.pios3;
                        plmodel.psalecnt     = 0;
                        plmodel.psumcnt      = 0;
                        plmodel.pleftcnt     = 0;
                        plmodel.pdesc        = model.premark;
                        plmodel.plupdatetime = DateTime.Now.ToString("yyyyMMddHHmmss");
                        plmodel.pls1         = "";
                        plmodel.pld1         = 0;
                        switch (model.ptype)
                        {
                        case 0:    //销售
                            plmodel.psalecnt += model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case 1:    //进货
                            plmodel.psumcnt  += model.pcnt;
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(model.pios2))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case 8:    //退回厂商
                            plmodel.psumcnt  -= model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case 2:    //订单
                            plmodel.pld1 += model.pcnt;
                            break;

                        case 3:    //盘赢
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(model.pios2))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case 4:    //盘亏
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case 5:    //退货
                        //plmodel.psalecnt -= model.pcnt;
                        //plmodel.pleftcnt += model.pcnt;
                        //break;
                        case 6:    //换货进
                            plmodel.psalecnt -= model.pcnt;
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(plmodel.pls1))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case 7:    //换货出
                            plmodel.psalecnt += model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;
                        }
                        bllPlib.Add(plmodel);
                    }
                    else
                    {
                        Jium.Model.plib plmodel = pllst[0];
                        plmodel.plupdatetime = DateTime.Now.ToString("yyyyMMddHHmmss");
                        switch (model.ptype)
                        {
                        case 0:    //销售
                            plmodel.psalecnt += model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case 1:    //进货
                            plmodel.psumcnt  += model.pcnt;
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(plmodel.pls1))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case 8:    //退回厂商
                            plmodel.psumcnt  -= model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case 2:    //订单
                            plmodel.pld1 += model.pcnt;
                            break;

                        case 3:    //盘赢
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(plmodel.pls1))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case 4:    //盘亏
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case 5:    //退货
                        //plmodel.psalecnt -= model.pcnt;
                        //plmodel.pleftcnt += model.pcnt;
                        //break;
                        case 6:    //换货进
                            plmodel.psalecnt -= model.pcnt;
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(plmodel.pls1))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case 7:    //换货出
                            plmodel.psalecnt += model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;
                        }
                        bllPlib.Update(plmodel);
                    }
                    Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
                    return;
                } while (false);
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存失败!", "add.aspx");
            }
            catch (Exception ex)
            {
                Maticsoft.Common.MessageBox.ShowAndRedirect(this, "Error!" + ex.Message, "add.aspx");
            }
        }
예제 #10
0
        public static bool AddPiorecord(Jium.Model.piorecord model)
        {
            var bres = true;

            try
            {
                do
                {
                    Jium.BLL.product bllProduct = new Jium.BLL.product();
                    Jium.BLL.plib    bllPlib    = new Jium.BLL.plib();
                    var where = string.Format("pcode='{0}'", model.pcode);
                    if (bllProduct.GetRecordCount(where) == 0)
                    {
                        Jium.Model.product pmodel = new Jium.Model.product();
                        pmodel.pcode      = model.pcode;
                        pmodel.pname      = model.pios3;
                        pmodel.pdesc      = model.premark;
                        pmodel.psaleprice = model.psaleprice;
                        pmodel.prealprice = model.prealprice;
                        pmodel.ptype      = model.pios5; //系列
                        pmodel.ps1        = model.pios4; //单位
                        pmodel.pisgroup   = 0;
                        bres = bllProduct.Add(pmodel);
                        if (!bres)
                        {
                            break;
                        }
                    }


                    Jium.BLL.piorecord bll = new Jium.BLL.piorecord();
                    bres = bll.Add(model);
                    if (!bres)
                    {
                        break;
                    }
                    var pllst = bllPlib.GetModelList(where);
                    if (pllst.Count == 0)
                    {
                        Jium.Model.plib plmodel = new Jium.Model.plib();
                        plmodel.pcode        = model.pcode;
                        plmodel.pname        = model.pios3;
                        plmodel.psalecnt     = 0;
                        plmodel.psumcnt      = 0;
                        plmodel.pleftcnt     = 0;
                        plmodel.pdesc        = model.premark;
                        plmodel.plupdatetime = DateTime.Now.ToString("yyyyMMddHHmmss");
                        plmodel.pls1         = "";
                        plmodel.pls2         = model.pios4;
                        plmodel.pld1         = 0;
                        switch ((PRODUCT_IO_TYPE)model.ptype)
                        {
                        case PRODUCT_IO_TYPE.SALE:    //销售
                            plmodel.psalecnt += model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case PRODUCT_IO_TYPE.ORDERIN:    //进货
                            plmodel.psumcnt  += model.pcnt;
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(model.pios2))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case PRODUCT_IO_TYPE.RETURN:    //退回厂商
                            plmodel.psumcnt  -= model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case PRODUCT_IO_TYPE.ORDERPLAN:    //订单
                            plmodel.pld1 += model.pcnt;
                            break;

                        case PRODUCT_IO_TYPE.SUMADD:    //盘赢
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(model.pios2))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case PRODUCT_IO_TYPE.SUMPLUS:    //盘亏
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case PRODUCT_IO_TYPE.REJECT:    //退货
                        //plmodel.psalecnt -= model.pcnt;
                        //plmodel.pleftcnt += model.pcnt;
                        //break;
                        case PRODUCT_IO_TYPE.RECHARGEIN:    //换货进
                            plmodel.psalecnt -= model.pcnt;
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(plmodel.pls1))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case PRODUCT_IO_TYPE.RECHARGEOUT:    //换货出
                            plmodel.psalecnt += model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;
                        }
                        bres = bllPlib.Add(plmodel);
                    }
                    else
                    {
                        Jium.Model.plib plmodel = pllst[0];
                        plmodel.plupdatetime = DateTime.Now.ToString("yyyyMMddHHmmss");
                        switch ((PRODUCT_IO_TYPE)model.ptype)
                        {
                        case PRODUCT_IO_TYPE.SALE:    //销售
                            plmodel.psalecnt += model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case PRODUCT_IO_TYPE.ORDERIN:    //进货
                            plmodel.psumcnt  += model.pcnt;
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(model.pios2))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case PRODUCT_IO_TYPE.RETURN:    //退回厂商
                            plmodel.psumcnt  -= model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case PRODUCT_IO_TYPE.ORDERPLAN:    //订单
                            plmodel.pld1 += model.pcnt;
                            break;

                        case PRODUCT_IO_TYPE.SUMADD:    //盘赢
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(model.pios2))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case PRODUCT_IO_TYPE.SUMPLUS:    //盘亏
                            plmodel.pleftcnt -= model.pcnt;
                            break;

                        case PRODUCT_IO_TYPE.REJECT:    //退货
                        //plmodel.psalecnt -= model.pcnt;
                        //plmodel.pleftcnt += model.pcnt;
                        //break;
                        case PRODUCT_IO_TYPE.RECHARGEIN:    //换货进
                            plmodel.psalecnt -= model.pcnt;
                            plmodel.pleftcnt += model.pcnt;
                            if (!plmodel.pls1.Contains(plmodel.pls1))
                            {
                                plmodel.pls1 += model.pios2 + ";";
                            }
                            break;

                        case PRODUCT_IO_TYPE.RECHARGEOUT:    //换货出
                            plmodel.psalecnt += model.pcnt;
                            plmodel.pleftcnt -= model.pcnt;
                            break;
                        }
                        bres = bllPlib.Update(plmodel);
                    }
                    return(bres);
                } while (false);
            }
            catch (Exception ex)
            {
                bres = false;
            }
            return(false);;
        }
예제 #11
0
        public static int BactchImportOrderData(string excelFilePath)
        {
            var iRes = ERR_CODE.SUCCESS;

            try
            {
                do
                {
                    if (string.IsNullOrEmpty(excelFilePath))
                    {
                        iRes = ERR_CODE.PARAM_EMPTY;
                        break;
                    }
                    if (!File.Exists(excelFilePath))
                    {
                        iRes = ERR_CODE.FILE_NOT_EXIST;
                        break;
                    }
                    if (!excelFilePath.ToLower().EndsWith(".xls") && !excelFilePath.ToLower().EndsWith(".xlsx"))
                    {
                        iRes = ERR_CODE.FILE_ERR_FORMAT;
                        break;
                    }
                    var      lstModel = new List <Jium.Model.piorecord>();
                    Workbook workbook = new Workbook(excelFilePath);
                    for (int n = 0; n < 2 /* workbook.Worksheets.Count*/; n++)
                    {
                        Cells cells   = workbook.Worksheets[n].Cells;
                        var   tabname = workbook.Worksheets[n].Name; // CodeName;
                                                                     //var fields = new List<string> { "", "", "", "", "", "", "", "" };

                        var orderid = DateTime.Now.Ticks;
                        for (int i = 1; i < cells.MaxDataRow + 1; i++)
                        {
                            var model = new Jium.Model.piorecord();
                            model.pcode    = cells[i, 1].StringValue.Trim();
                            model.pguestid = 0;
                            model.psalerid = 0;
                            model.ptime    = DateTime.Now.ToString("yyyyMMddHHmmss");
                            model.pios3    = cells[i, 2].StringValue.Trim();
                            model.premark  = cells[i, 9].StringValue.Trim();
                            var sCnt = cells[i, 4].StringValue.Trim();
                            if (string.IsNullOrWhiteSpace(sCnt) || sCnt.Trim() == "-" || sCnt.Trim() == "0")
                            {
                                continue;
                            }
                            model.pcnt = int.Parse(sCnt);
                            decimal saleprice = 0;
                            if (cells[i, 5].StringValue.Trim() != "")
                            {
                                saleprice = decimal.Parse(cells[i, 5].StringValue.Trim());
                            }
                            model.psaleprice = saleprice;
                            decimal zekou = 0;
                            if (cells[i, 7].StringValue.Trim() != "")
                            {
                                zekou = decimal.Parse(cells[i, 7].StringValue.Trim());
                            }
                            model.pzekou = zekou;
                            //decimal realprice = 0;
                            //if (cells[i, 5].StringValue.Trim() != "") realprice = decimal.Parse(cells[i, 5].StringValue.Trim());
                            model.prealprice = saleprice * zekou;
                            model.ptype      = (int)PRODUCT_IO_TYPE.ORDERPLAN;
                            model.pios4      = cells[i, 3].StringValue.Trim(); //单位
                            model.pios5      = cells[i, 0].StringValue.Trim(); //系列
                            model.pios1      = tabname;
                            model.pios2      = "";
                            lstModel.Add(model);
                            //for (int j = 0; j < cells.MaxDataColumn + 1; j++)
                            //{
                            //    string s = cells[i, j].StringValue.Trim();

                            //}
                        }
                    }
                    foreach (var model in lstModel)
                    {
                        if (!AddPiorecord(model))
                        {
                            iRes = ERR_CODE.FAIL;
                            break;
                        }
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                iRes = ERR_CODE.EXCEPTION;
            }

            return((int)iRes);
        }
예제 #12
0
        public static int BactchImportOrderInData(string excelFilePath)
        {
            var iRes = ERR_CODE.SUCCESS;

            try
            {
                do
                {
                    if (string.IsNullOrEmpty(excelFilePath))
                    {
                        iRes = ERR_CODE.PARAM_EMPTY;
                        break;
                    }
                    if (!File.Exists(excelFilePath))
                    {
                        iRes = ERR_CODE.FILE_NOT_EXIST;
                        break;
                    }
                    if (!excelFilePath.ToLower().EndsWith(".xls") && !excelFilePath.ToLower().EndsWith(".xlsx"))
                    {
                        iRes = ERR_CODE.FILE_ERR_FORMAT;
                        break;
                    }
                    Workbook workbook = new Workbook(excelFilePath);
                    Cells    cells    = workbook.Worksheets[0].Cells;
                    var      tabname  = workbook.Worksheets[0].Name;// CodeName;
                    var      fields   = new List <string> {
                        "", "", "", "", "", "", "", ""
                    };
                    var lstModel = new List <Jium.Model.piorecord>();
                    var orderid  = DateTime.Now.Ticks;
                    for (int i = 1; i < cells.MaxDataRow + 1; i++)
                    {
                        var model = new Jium.Model.piorecord();
                        model.pcode      = cells[i, 10].StringValue.Trim();
                        model.pguestid   = 0;
                        model.psalerid   = 0;
                        model.ptime      = DateTime.Now.ToString("yyyyMMddHHmmss");
                        model.pios3      = cells[i, 11].StringValue.Trim();
                        model.premark    = cells[i, 12].StringValue.Trim();
                        model.pcnt       = int.Parse(cells[i, 13].StringValue.Trim());
                        model.psaleprice = decimal.Parse(cells[i, 14].StringValue.Trim());
                        model.pzekou     = decimal.Parse(cells[i, 16].StringValue.Trim());
                        model.prealprice = decimal.Parse(cells[i, 17].StringValue.Trim());
                        model.ptype      = (int)PRODUCT_IO_TYPE.ORDERIN;
                        model.pios4      = "1";                             //cells[i, 3].StringValue.Trim();//单位
                        model.pios5      = cells[i, 21].StringValue.Trim(); //系列
                        model.pios1      = orderid.ToString();
                        model.pios2      = "";
                        lstModel.Add(model);
                        //for (int j = 0; j < cells.MaxDataColumn + 1; j++)
                        //{
                        //    string s = cells[i, j].StringValue.Trim();

                        //}
                    }

                    foreach (var model in lstModel)
                    {
                        if (!AddPiorecord(model))
                        {
                            iRes = ERR_CODE.FAIL;
                            break;
                        }
                    }
                } while (false);
            }
            catch (Exception ex)
            {
                iRes = ERR_CODE.EXCEPTION;
            }

            return((int)iRes);
        }
예제 #13
0
        protected void btnConfirmSale_Click(object sender, EventArgs e)
        {
            try
            {
                //#warning 代码生成警告:请检查确认真实主键的名称和类型是否正确
                string orderid  = DateTime.Now.ToString("yyyyMMddHHmmss");
                var    lstModel = new List <Jium.Model.piorecord>();

                for (int i = 0; i < gridViewBuy.Rows.Count; i++)
                {
                    var model = new Jium.Model.piorecord();
                    model.pcode      = gridViewBuy.Rows[i].Cells[0].Text;
                    model.pios3      = gridViewBuy.Rows[i].Cells[1].Text;
                    model.psaleprice = decimal.Parse(gridViewBuy.Rows[i].Cells[3].Text);
                    model.pcnt       = int.Parse(gridViewBuy.Rows[i].Cells[5].Text);
                    model.pzekou     = decimal.Parse(gridViewBuy.Rows[i].Cells[6].Text);
                    model.psalerid   = 0;
                    model.ptype      = (int)PRODUCT_IO_TYPE.SALE;;
                    model.ptime      = orderid;
                    model.pguestid   = int.Parse(txtCcode.Text);
                    var txtNum = gridViewBuy.Rows[i].Cells[4].Text.Trim();
                    model.piod1 = string.IsNullOrWhiteSpace(txtNum.Replace("&nbsp;", "")) ? 0 : int.Parse(gridViewBuy.Rows[i].Cells[4].Text); //服务
                    model.pios4 = gridViewBuy.Rows[i].Cells[2].Text.Replace("&nbsp;", "");                                                    //单位
                    model.piod5 = 5;                                                                                                          //model.pios5 = cells[i, 0].StringValue.Trim();//系列
                    model.pios1 = "销售";
                    lstModel.Add(model);
                }
                ERR_CODE iRes = ERR_CODE.SUCCESS;
                ///事务回滚机制???
                var bllCustomeService = new Jium.BLL.consumerservice();
                foreach (var model in lstModel)
                {
                    if (!Ctrl.piorecord.AddPiorecord(model))
                    {
                        iRes = ERR_CODE.FAIL;
                        break;
                    }
                    if (model.piod1 > 0)//add service for guset
                    {
                        var consumerservice = new Jium.Model.consumerservice();
                        consumerservice.ccode      = model.pguestid.ToString();
                        consumerservice.csnum      = model.piod1 ?? 0;
                        consumerservice.cstype     = model.pios3;
                        consumerservice.csleft     = model.piod1 ?? 0;
                        consumerservice.csiostatus = 0;
                        consumerservice.cstime0    = orderid;
                        consumerservice.csd5       = "5";
                        bllCustomeService.Add(consumerservice);
                    }
                }
                //update guest info
                var consumerBll = new Jium.BLL.consumer();
                var lstConsumer = consumerBll.GetModelList(string.Format("ccode='{0}' and csd5=5", txtCcode.Text.Trim()));
                if (lstConsumer.Count == 0)
                {
                    ///error
                    ///return;
                }
                lstConsumer[0].css1   = orderid;
                lstConsumer[0].csum  += decimal.Parse(txtSumReal.Text);
                lstConsumer[0].clevel = Jium.BLL.consumer.getLevelByConsume(lstConsumer[0].csum).ToString();//get from csum
                consumerBll.Update(lstConsumer[0]);

                Maticsoft.Common.MessageBox.ShowAndRedirects(this, "操作完成!", "/default.aspx");
            }
            catch (Exception ex)
            {
                Maticsoft.Common.MessageBox.Show(this, "系统错误:" + ex.Message);
                return;
            }
        }