コード例 #1
0
        private void Button2_Click(object sender, System.EventArgs e)
        {
            //生产产品入库
            DataTable dtSalesSerial = GetProduct();
            ArrayList alSalesSerial = new ArrayList();

            if (dtSalesSerial.Rows.Count > 0)
            {
                foreach (DataRow dr in dtSalesSerial.Rows)
                {
                    SalesSerial ps = new SalesSerial(dr);
                    ps.cndCreateDate = Convert.ToDateTime(TextBox1.Text);
                    ps.cnvcOperID    = oper.strLoginID;
                    ps.cnvcDeptID    = ddlDept.SelectedValue;

                    alSalesSerial.Add(ps);
                }

                OperLog ol = new OperLog();
                ol.cnvcDeptID   = oper.strDeptID;
                ol.cnvcOperID   = oper.strLoginID;
                ol.cnvcOperType = "销售产品入库";

                ProductFacade pf = new ProductFacade();
                pf.AddSalesSerial(alSalesSerial, ol);

                this.Popup("销售产品入库成功!");

                //清理数据

                Session.Remove("tbSalesSerial");
                BindGrid();
            }
        }
コード例 #2
0
        public void AddSalesSerial(ArrayList alSalesSerial, OperLog operLog)       //,BusiLog busiLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    SerialNo serialNo = new SerialNo();
                    serialNo.cnvcFill    = "0";
                    serialNo.cnnSerialNo = Convert.ToInt32(EntityMapping.Create(serialNo, trans));
                    for (int i = 0; i < alSalesSerial.Count; i++)
                    {
                        SalesSerial salesSerial = (SalesSerial)alSalesSerial[i];
                        salesSerial.cndOperDate = dtSysTime;
                        salesSerial.cnnSerialNo = serialNo.cnnSerialNo;
                        EntityMapping.Create(salesSerial, trans);

                        SalesSerialLog salesSerialLog = new SalesSerialLog(salesSerial.ToTable());
                        //salesSerialLog.cnnSerialNo = null;
                        salesSerialLog.cnnSalesSerialNo = serialNo.cnnSerialNo;
                        EntityMapping.Create(salesSerialLog, trans);
                    }

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "销售入库,生产流水:" + serialNo.cnnSerialNo.ToString();

                    EntityMapping.Create(operLog, trans);

                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
コード例 #3
0
        public void AdjustSalesSerial_Delete(SalesSerial salesSerial, OperLog operLog)       //,BusiLog busiLog)
        {
            using (SqlConnection conn = ConnectionPool.BorrowConnection())
            {
                //conn.Open();

                SqlTransaction trans = conn.BeginTransaction();
                try
                {
                    string   strSysTime = SqlHelper.ExecuteScalar(trans, CommandType.Text, "select getdate()").ToString();
                    DateTime dtSysTime  = DateTime.Parse(strSysTime);

                    SalesSerial oldSalesSerial = EntityMapping.Get(salesSerial, trans) as SalesSerial;
                    if (oldSalesSerial == null)
                    {
                        throw new Exception("未找到对应销售流水的产品!");
                    }

                    oldSalesSerial.cnnReduceCount = salesSerial.cnnReduceCount;
                    oldSalesSerial.cnvcOperID     = operLog.cnvcOperID;
                    oldSalesSerial.cndOperDate    = dtSysTime;
                    EntityMapping.Delete(oldSalesSerial, trans);

                    SalesSerialLog salesSerialLog = new SalesSerialLog(oldSalesSerial.ToTable());
                    salesSerialLog.cnnSalesSerialNo = oldSalesSerial.cnnSerialNo;
                    EntityMapping.Create(salesSerialLog, trans);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "销售删除,生产流水:" + oldSalesSerial.cnnSerialNo.ToString() + ",产品编码:" + salesSerial.cnvcCode;

                    EntityMapping.Create(operLog, trans);

                    trans.Commit();
                }
                catch (SqlException sex)
                {
                    trans.Rollback();
                    LogAdapter.WriteDatabaseException(sex);
                    throw sex;
                }
                catch (Exception ex)
                {
                    trans.Rollback();
                    LogAdapter.WriteFeaturesException(ex);
                    throw ex;
                }
                finally
                {
                    ConnectionPool.ReturnConnection(conn);
                }
            }
        }
コード例 #4
0
        private void MyDataGrid_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
        {
            string        strSerialNo;  // = e.Item.Cells[0].Text;
            string        strGoodsID;   // = e.Item.Cells[1].Text;
            string        strCount;     // = e.Item.Cells[4].Text;
            SalesSerial   ps;
            OperLog       ol;
            ProductFacade pf;

            DataRow[] drs;
            DataTable dtSales = GetProduct();

            switch (e.CommandName)
            {
            case "AdjustAdd":
                strSerialNo = e.Item.Cells[0].Text;
                strGoodsID  = e.Item.Cells[1].Text;
                strCount    = e.Item.Cells[4].Text;
                string strAddCount = ((TextBox)e.Item.Cells[5].Controls[1]).Text;

                if (strAddCount == "")
                {
                    this.Popup("请输入调增量!");
                    return;
                }
                if (!this.JudgeIsNum(strAddCount))
                {
                    this.Popup("请输入数字!");
                    return;
                }
                if (Convert.ToInt32(strAddCount) <= 0)
                {
                    this.Popup("调增量必须大于零!");
                    return;
                }

                drs = dtSales.Select("cnvcCode='" + strGoodsID + "' and cnnSerialNo=" + strSerialNo);
                if (drs.Length > 0)
                {
                    drs[0]["cnnAddCount"] = strAddCount;
                    drs[0]["cnnSum"]      = Convert.ToInt32(strCount) + Convert.ToInt32(strAddCount);
                }
                ps             = new SalesSerial();
                ps.cnnSerialNo = Convert.ToInt32(strSerialNo);
                ps.cnvcCode    = strGoodsID;
                ps.cnnAddCount = Convert.ToInt32(strAddCount);

                ol              = new OperLog();
                ol.cnvcDeptID   = oper.strDeptID;
                ol.cnvcOperID   = oper.strLoginID;
                ol.cnvcOperType = "销售产品调增";

                pf = new ProductFacade();
                pf.AdjustSalesSerial_Add(ps, ol);


                SetProduct(dtSales);
                this.Popup("调增成功!");
                BindGrid();
                break;

            case "AdjustReduce":
                strSerialNo = e.Item.Cells[0].Text;
                strGoodsID  = e.Item.Cells[1].Text;
                strCount    = e.Item.Cells[4].Text;
                string strReduceCount = ((TextBox)e.Item.Cells[6].Controls[1]).Text;

                if (strReduceCount == "")
                {
                    this.Popup("请输入调减量!");
                    return;
                }
                if (!this.JudgeIsNum(strReduceCount))
                {
                    this.Popup("请输入数字!");
                    return;
                }
                if (Convert.ToInt32(strReduceCount) <= 0)
                {
                    this.Popup("调减量必须大于零!");
                    return;
                }

                if (Convert.ToInt32(strCount) - Convert.ToInt32(strReduceCount) <= 0)
                {
                    this.Popup("调减量必须小于销售量!");
                    return;
                }
                drs = dtSales.Select("cnvcCode='" + strGoodsID + "' and cnnSerialNo=" + strSerialNo);
                if (drs.Length > 0)
                {
                    drs[0]["cnnReduceCount"] = strReduceCount;
                    drs[0]["cnnSum"]         = Convert.ToInt32(strCount) - Convert.ToInt32(strReduceCount);
                }

                ps                = new SalesSerial();
                ps.cnnSerialNo    = Convert.ToInt32(strSerialNo);
                ps.cnvcCode       = strGoodsID;
                ps.cnnReduceCount = Convert.ToInt32(strReduceCount);


                ol              = new OperLog();
                ol.cnvcDeptID   = oper.strDeptID;
                ol.cnvcOperID   = oper.strLoginID;
                ol.cnvcOperType = "销售产品调减";

                pf = new ProductFacade();
                pf.AdjustSalesSerial_Reduce(ps, ol);

                SetProduct(dtSales);
                this.Popup("调减成功!");
                BindGrid();
                break;

            case "Delete":
                strSerialNo = e.Item.Cells[0].Text;
                strGoodsID  = e.Item.Cells[1].Text;
                //strCount = e.Item.Cells[4].Text;
                drs = dtSales.Select("cnvcCode='" + strGoodsID + "' and cnnSerialNo=" + strSerialNo);
                if (drs.Length > 0)
                {
                    dtSales.Rows.Remove(drs[0]);
                    //drs[0]["cnnCount"] = strCount;
                }

                ps             = new SalesSerial();
                ps.cnnSerialNo = Convert.ToInt32(strSerialNo);
                ps.cnvcCode    = strGoodsID;

                ol              = new OperLog();
                ol.cnvcDeptID   = oper.strDeptID;
                ol.cnvcOperID   = oper.strLoginID;
                ol.cnvcOperType = "销售产品删除";

                pf = new ProductFacade();
                pf.AdjustSalesSerial_Delete(ps, ol);

                SetProduct(dtSales);
                this.Popup("销售产品删除成功!");

                if ((this.MyDataGrid.CurrentPageIndex == MyDataGrid.PageCount - 1) && MyDataGrid.Items.Count == 1)
                {
                    if (MyDataGrid.CurrentPageIndex - 1 > 1)
                    {
                        MyDataGrid.CurrentPageIndex = MyDataGrid.CurrentPageIndex - 1;
                    }
                    else
                    {
                        MyDataGrid.CurrentPageIndex = 0;
                    }
                }

                BindGrid();
                break;
            }
        }