Beispiel #1
0
 private void ShowInfo(int id)
 {
     Jium.BLL.product   bll   = new Jium.BLL.product();
     Jium.Model.product model = bll.GetModel(id);
     this.lblid.Text         = model.id.ToString();
     this.txtpcode.Text      = model.pcode;
     this.txtpname.Text      = model.pname;
     this.txtpsaleprice.Text = model.psaleprice.ToString();
     this.txtprealprice.Text = model.prealprice.ToString();
     this.txtptype.Text      = model.ptype;
     this.txtpisgroup.Text   = model.pisgroup.ToString();
     this.txtpdesc.Text      = model.pdesc;
     this.txtps1.Text        = model.ps1;
     this.txtps2.Text        = model.ps2;
     this.txtps3.Text        = model.ps3;
     this.txtps4.Text        = model.ps4;
     this.txtps5.Text        = model.ps5;
     this.txtpd1.Text        = model.pd1.ToString();
     this.txtpd2.Text        = model.pd2.ToString();
     this.txtpd3.Text        = model.pd3.ToString();
     this.txtpd4.Text        = model.pd4.ToString();
     this.txtpd5.Text        = model.pd5.ToString();
     this.txtpdc1.Text       = model.pdc1.ToString();
     this.txtpdc2.Text       = model.pdc2.ToString();
     this.txtpdc3.Text       = model.pdc3.ToString();
 }
Beispiel #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();
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         Jium.BLL.product bll = new Jium.BLL.product();
         if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
         {
             int id = (Convert.ToInt32(Request.Params["id"]));
             bll.Delete(id);
             Response.Redirect("list.aspx");
         }
     }
 }
Beispiel #4
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);
        }
Beispiel #5
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtpcode.Text.Trim().Length == 0)
            {
                strErr += "pcode不能为空!\\n";
            }
            if (this.txtpname.Text.Trim().Length == 0)
            {
                strErr += "pname不能为空!\\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 (this.txtptype.Text.Trim().Length == 0)
            {
                strErr += "ptype不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtpisgroup.Text))
            {
                strErr += "pisgroup格式错误!\\n";
            }

            /*
             *          if(this.txtpdesc.Text.Trim().Length==0)
             *          {
             *                  strErr+="pdesc不能为空!\\n";
             *          }
             *          if(this.txtps1.Text.Trim().Length==0)
             *          {
             *                  strErr+="ps1不能为空!\\n";
             *          }
             *          if(this.txtps2.Text.Trim().Length==0)
             *          {
             *                  strErr+="ps2不能为空!\\n";
             *          }
             *          if(this.txtps3.Text.Trim().Length==0)
             *          {
             *                  strErr+="ps3不能为空!\\n";
             *          }
             *          if(this.txtps4.Text.Trim().Length==0)
             *          {
             *                  strErr+="ps4不能为空!\\n";
             *          }
             *          if(this.txtps5.Text.Trim().Length==0)
             *          {
             *                  strErr+="ps5不能为空!\\n";
             *          }
             *          if(!PageValidate.IsNumber(txtpd1.Text))
             *          {
             *                  strErr+="pd1格式错误!\\n";
             *          }
             *          if(!PageValidate.IsNumber(txtpd2.Text))
             *          {
             *                  strErr+="pd2格式错误!\\n";
             *          }
             *          if(!PageValidate.IsNumber(txtpd3.Text))
             *          {
             *                  strErr+="pd3格式错误!\\n";
             *          }
             *          if(!PageValidate.IsNumber(txtpd4.Text))
             *          {
             *                  strErr+="pd4格式错误!\\n";
             *          }
             *          if(!PageValidate.IsNumber(txtpd5.Text))
             *          {
             *                  strErr+="pd5格式错误!\\n";
             *          }
             *          if(!PageValidate.IsDecimal(txtpdc1.Text))
             *          {
             *                  strErr+="pdc1格式错误!\\n";
             *          }
             *          if(!PageValidate.IsDecimal(txtpdc2.Text))
             *          {
             *                  strErr+="pdc2格式错误!\\n";
             *          }
             *          if(!PageValidate.IsDecimal(txtpdc3.Text))
             *          {
             *                  strErr+="pdc3格式错误!\\n";
             *          }
             */
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int     id         = int.Parse(this.lblid.Text);
            string  pcode      = this.txtpcode.Text;
            string  pname      = this.txtpname.Text;
            decimal psaleprice = decimal.Parse(this.txtpsaleprice.Text);
            decimal prealprice = decimal.Parse(this.txtprealprice.Text);
            string  ptype      = this.txtptype.Text;
            int     pisgroup   = int.Parse(this.txtpisgroup.Text);
            string  pdesc      = this.txtpdesc.Text;
            string  ps1        = this.txtps1.Text;
            string  ps2        = this.txtps2.Text;
            string  ps3        = this.txtps3.Text;
            string  ps4        = this.txtps4.Text;
            string  ps5        = this.txtps5.Text;
            int     pd1        = string.IsNullOrWhiteSpace(this.txtpd1.Text)? 0:int.Parse(this.txtpd1.Text);
            int     pd2        = string.IsNullOrWhiteSpace(this.txtpd2.Text) ? 0 : int.Parse(this.txtpd2.Text);
            int     pd3        = string.IsNullOrWhiteSpace(this.txtpd3.Text) ? 0 : int.Parse(this.txtpd3.Text);
            int     pd4        = string.IsNullOrWhiteSpace(this.txtpd4.Text) ? 0 : int.Parse(this.txtpd4.Text);
            int     pd5        = string.IsNullOrWhiteSpace(this.txtpd5.Text) ? 0 : int.Parse(this.txtpd5.Text);
            decimal pdc1       = string.IsNullOrWhiteSpace(this.txtpdc1.Text) ? 0 : decimal.Parse(this.txtpdc1.Text);
            decimal pdc2       = string.IsNullOrWhiteSpace(this.txtpdc2.Text) ? 0 : decimal.Parse(this.txtpdc2.Text);
            decimal pdc3       = string.IsNullOrWhiteSpace(this.txtpdc3.Text) ? 0 : decimal.Parse(this.txtpdc3.Text);


            Jium.Model.product model = new Jium.Model.product();
            model.id         = id;
            model.pcode      = pcode;
            model.pname      = pname;
            model.psaleprice = psaleprice;
            model.prealprice = prealprice;
            model.ptype      = ptype;
            model.pisgroup   = pisgroup;
            model.pdesc      = pdesc;
            model.ps1        = ps1;
            model.ps2        = ps2;
            model.ps3        = ps3;
            model.ps4        = ps4;
            model.ps5        = ps5;
            model.pd1        = pd1;
            model.pd2        = pd2;
            model.pd3        = pd3;
            model.pd4        = pd4;
            model.pd5        = pd5;
            model.pdc1       = pdc1;
            model.pdc2       = pdc2;
            model.pdc3       = pdc3;

            Jium.BLL.product bll = new Jium.BLL.product();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Beispiel #6
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");
            }
        }
Beispiel #7
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);;
        }