Ejemplo n.º 1
0
        /// <summary>
        /// 窗体加载事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SalesLibrary_Load(object sender, EventArgs e)
        {
            txtDelivery.Text = showCode;
            lblcCusName.Text = cCusName;
            Clear();
            string errMsg;

            try
            {
                //显示等待
                Cursor.Current = Cursors.WaitCursor;
                dispatchList   = new BLL.Consignment().Load(cDLCode, out errMsg);
                if (dispatchList != null)
                {
                    //把销售发货对象转换成销售出库对象
                    rdRecord          = EntityConvert.ConvertToRdrecord(dispatchList);
                    btnSource.Enabled = true;

                    txtBarcode.Focus();
                }
                else
                {
                    MessageBox.Show(errMsg);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                Cursor.Current = Cursors.Default;
            }
        }
Ejemplo n.º 2
0
        private void btAdd_Click(object sender, System.EventArgs e)
        {
            strArriveDate = Request.Form["txtArvDate"].ToString();
            if (strArriveDate == "" || strArriveDate == null)
            {
                this.Popup("到货时间不能为空,请重新选择时间!");
                return;
            }
            Entity.RdRecord rd = new RdRecord();
            rd.cnvcCode      = this.txtEnterCode.Text.Trim();
            rd.cnvcRdCode    = "RD001";
            rd.cnvcRdFlag    = "0";
            rd.cnvcIsLsQuery = this.ddlIsLsQuery.SelectedValue;
            rd.cnvcWhCode    = this.ddlWhouse.SelectedValue;
            rd.cnvcDepID     = this.ddlDeptID.SelectedValue;
            rd.cnvcOperName  = this.oper.strOperName;
            rd.cnvcCusCode   = "";
            //rd.cnvcProBatch="";
            rd.cnvcComments = this.txtComments.Text.Trim();
            rd.cnvcMaker    = this.oper.strOperName;
            //rd.cnvcMPoCode="";
            rd.cnvcShipAddress = this.txtShipAddress.Text.Trim();
            rd.cndARVDate      = DateTime.Parse(strArriveDate);
            rd.cnvcARVAddress  = this.txtArvAddress.Text.Trim();
            rd.cnvcState       = "0";

            if (rd.cnvcCode == "" || rd.cnvcCode.Length != 13)
            {
                this.Popup("采购入库单号不正确!");
                return;
            }
            if (rd.cnvcWhCode == "")
            {
                this.Popup("仓库不能为空!");
                return;
            }

            Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog();
            ol.cnvcOperType = "添加采购入库主单";
            ol.cnvcOperID   = this.oper.strLoginID;
            ol.cnvcDeptID   = this.oper.strDeptID;

            StorageFacade sto = new StorageFacade();
            int           ret = sto.AddRdRecordCom("RD001", ol, rd);

            if (ret > 0)
            {
                this.Popup("添加采购入库单内容成功!");
            }
            else
            {
                this.Popup("添加采购入库单内容失败!");
            }
        }
Ejemplo n.º 3
0
        private void btAdd_Click(object sender, System.EventArgs e)
        {
            strArriveDate = Request.Form["txtArvDate"].ToString();
            if (strArriveDate == "" || strArriveDate == null)
            {
                this.Popup("到货时间不能为空,请重新选择时间!");
                this.ClientScript.RegisterStartupScript(this.GetType(), "hide", "<script lanaguage=javascript>ShowHide('1','none');</script>");
                return;
            }
            Entity.RdRecord rd = new RdRecord();
            rd.cnvcCode        = this.txtEnterCode.Text.Trim();
            rd.cnvcRdCode      = "RD002";
            rd.cnvcRdFlag      = "1";
            rd.cnvcWhCode      = this.ddlWhouse.SelectedValue;
            rd.cnvcDepID       = this.ddlDeptID.SelectedValue;
            rd.cnvcOperName    = this.oper.strOperName;
            rd.cnvcComments    = this.txtComments.Text.Trim();
            rd.cnvcMaker       = this.oper.strOperName;
            rd.cnvcShipAddress = this.txtShipAddress.Text.Trim();
            rd.cndARVDate      = DateTime.Parse(strArriveDate);
            rd.cnvcARVAddress  = this.txtArvAddress.Text.Trim();
            rd.cnvcState       = "0";

            if (rd.cnvcCode == "" || rd.cnvcCode.Length != 13)
            {
                this.Popup("采购退货单号不正确!");
                return;
            }
            if (rd.cnvcWhCode == "")
            {
                this.Popup("仓库不能为空!");
                return;
            }

            Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog();
            ol.cnvcOperType = "添加采购退货主单";
            ol.cnvcOperID   = this.oper.strLoginID;
            ol.cnvcDeptID   = this.oper.strDeptID;

            StorageFacade sto = new StorageFacade();
            int           ret = sto.AddRdRecordCom("RD002", ol, rd);

            if (ret > 0)
            {
                this.Popup("添加采购退货单内容成功!");
            }
            else
            {
                this.Popup("添加采购退货单内容失败!");
            }
        }
Ejemplo n.º 4
0
        private void btMod_Click(object sender, System.EventArgs e)
        {
            strArriveDate = Request.Form["txtArvDate"].ToString();
            if (strArriveDate == "" || strArriveDate == null)
            {
                this.Popup("到货时间不能为空,请重新选择时间!");
                return;
            }
            Entity.RdRecord rdrm = new RdRecord();
            rdrm.cnnRdID         = int.Parse(this.txtRdID.Text.Trim());
            rdrm.cnvcIsLsQuery   = this.ddlIsLsQuery.SelectedValue;
            rdrm.cndARVDate      = DateTime.Parse(strArriveDate);
            rdrm.cnvcShipAddress = this.txtShipAddress.Text.Trim();
            rdrm.cnvcARVAddress  = this.txtArvAddress.Text.Trim();
            rdrm.cnvcComments    = this.txtComments.Text.Trim();
            rdrm.cnvcModer       = oper.strOperName;

            if (rdrm.cnnRdID.ToString() == "" || rdrm.cnnRdID == 0)
            {
                this.Popup("采购入库单主表标识不正确!");
                return;
            }

            Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog();
            ol.cnvcOperType = "修改采购入库主单";
            ol.cnvcOperID   = this.oper.strLoginID;
            ol.cnvcDeptID   = this.oper.strDeptID;

            StorageFacade sto = new StorageFacade();
            int           ret = sto.UpdateRdRecordCom("RD001", ol, rdrm);

            if (ret > 0)
            {
                this.Popup("修改采购入库单内容成功!");
            }
            else
            {
                this.Popup("修改采购入库单内容失败!");
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 销售出库:新增单据
        /// </summary>
        /// <param name="rdRecord"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        public bool Save(RdRecord rdRecord, out string errMsg)
        {
            BLL.Service.RdRecord tRdRecord = new BLL.Service.RdRecord();
            //主表转换
            EntityConvert.ConvertClass <RdRecord, BLL.Service.RdRecord>(rdRecord, tRdRecord);

            //循环遍历子表
            BLL.Service.RdRecords tRdRecords;
            //初始化目标数组
            tRdRecord.List = new BLL.Service.RdRecords[rdRecord.List.Count];
            int i = 0;

            foreach (RdRecords rdRecords in rdRecord.List)
            {
                tRdRecords = new BLL.Service.RdRecords();
                EntityConvert.ConvertClass <RdRecords, BLL.Service.RdRecords>(rdRecords, tRdRecords);
                tRdRecords.SerialList = rdRecords.SerialList.ToArray();//标签序列号集合
                tRdRecord.List[i++]   = tRdRecords;
            }

            return(Common.Instance.Service.ST_SaleOut_Save(Common.Instance.User, tRdRecord, out errMsg));
        }
Ejemplo n.º 6
0
        public void AssignOut(string strProduceSerialNo, OperLog operLog, string strWarehouse)
        {
            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);

                    string    strsql1      = "SELECT * FROM tbProduceLog WHERE cnvcProduceState='6' and cnnProduceSerialNo=" + strProduceSerialNo;
                    DataTable dtProduceLog = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql1);
                    //rr.cndMakeDate = dtSysTime;
                    //EntityMapping.Create(rr,trans);
                    if (dtProduceLog.Rows.Count == 0)
                    {
                        throw new Exception("生产计划不在分货状态!");
                    }
                    Entity.ProduceLog pl = new ProduceLog(dtProduceLog);

                    string    strsql2           = "select * from tbproducechecklog WHERE cnnAssignCount>0 and cnnproduceserialno=" + strProduceSerialNo;
                    DataTable dtProduceCheckLog = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql2);
                    if (dtProduceCheckLog.Rows.Count == 0)
                    {
                        throw new Exception("分货出库产品数量都为0");
                    }

                    DataTable dtInv             = SingleTableQuery.ExcuteQuery("tbInventory", trans);
                    DataTable dtComputationUnit = SingleTableQuery.ExcuteQuery("tbComputationUnit", trans);

                    string    strsql3     = "select * from tbassignlog where cnnproduceserialno=" + strProduceSerialNo;
                    DataTable dtAssignLog = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strsql3);
                    if (dtAssignLog.Rows.Count == 0)
                    {
                        throw new Exception("未找到分货流水");
                    }
                    Entity.AssignLog al = new AssignLog(dtAssignLog);

                    Entity.RdRecord rr = new RdRecord();
                    rr.cnvcRdCode = "RD010";
                    rr.cnvcRdFlag = "0";
                    rr.cnvcWhCode = strWarehouse;
                    rr.cnvcDepID  = pl.cnvcProduceDeptID;
                    //rr.cnvcOperName = operLog.cnvcop
                    rr.cnvcComments  = "分货出库";
                    rr.cnvcMaker     = operLog.cnvcOperID;
                    rr.cnnProorderID = pl.cnnProduceSerialNo;
                    rr.cnvcState     = "2";
                    rr.cndMakeDate   = dtSysTime;
                    long rrid = EntityMapping.Create(rr, trans);

                    foreach (DataRow drProduceCheckLog in dtProduceCheckLog.Rows)
                    {
                        Entity.ProduceCheckLog pcl = new ProduceCheckLog(drProduceCheckLog);


                        Entity.RdRecordDetail rrd = new RdRecordDetail();
                        rrd.cnvcFlag   = "0";
                        rrd.cndExpDate = pcl.cndExpDate;                    //Convert.ToDateTime(this.txtProduceDate.Text).AddDays(pc.cnnDays).AddDays(Convert.ToDouble(txtDays.Text));//Convert.ToDateTime(this.txtExpDate.Text);
                        rrd.cndMdate   = pcl.cndMDate;                      //Convert.ToDateTime(this.txtProduceDate.Text);
                        rrd.cnnRdID    = Convert.ToDecimal(rrid);
                        rrd.cnvcPOID   = al.cnnAssignSerialNo.ToString();

                        DataRow[] drinvs = dtInv.Select("cnvcInvCode='" + pcl.cnvcInvCode + "'");
                        if (drinvs.Length == 0)
                        {
                            throw new Exception(pcl.cnvcInvCode + "存货档案未设置");
                        }
                        Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory(drinvs[0]);


                        rrd.cnvcInvCode     = inv.cnvcInvCode;
                        rrd.cnvcGroupCode   = inv.cnvcGroupCode;
                        rrd.cnvcComunitCode = inv.cnvcSTComUnitCode;

                        DataRow[] drcus = dtComputationUnit.Select("cnvcGroupCode='" + inv.cnvcGroupCode + "' and cnbMainUnit=1");
                        if (drcus.Length == 0)
                        {
                            throw new Exception(inv.cnvcGroupCode + "未设置主计量单位");
                        }
                        decimal   dchangerate    = Convert.ToDecimal(drcus[0]["cnichangrate"].ToString());
                        DataRow[] drcus1         = dtComputationUnit.Select("cnvcGroupCode='" + inv.cnvcGroupCode + "' and cnvcComUnitCode='" + inv.cnvcSTComUnitCode + "'");
                        decimal   dchangerate_st = Convert.ToDecimal(drcus1[0]["cnichangrate"].ToString());

//						string strcssql = "SELECT * FROM tbCurrentStock WHERE cnvcWhCode='"+strWarehouse+"' AND cnvcInvCode='"+pcl.cnvcInvCode+"'";
//						DataTable dtcs = SqlHelper.ExecuteDataTable(trans,CommandType.Text,strcssql);


                        string strcssql = "SELECT * FROM tbCurrentStock WHERE cnvcWhCode='" + strWarehouse + "' AND cnvcInvCode='" + pcl.cnvcInvCode + "'"
                                          + " and CONVERT(char(10),isnull(cndExpDate,''),121)>=CONVERT(char(10),getdate(),121) ";
                        string strcssql2 = "SELECT isnull(sum(cnnAvaQuantity),0) FROM tbCurrentStock WHERE cnvcWhCode='" + strWarehouse + "' AND cnvcInvCode='" + pcl.cnvcInvCode + "'"
                                           + " and CONVERT(char(10),isnull(cndExpDate,''),121)>=CONVERT(char(10),getdate(),121) ";
                        DataTable dtcs         = SqlHelper.ExecuteDataTable(trans, CommandType.Text, strcssql);
                        decimal   davaquantity = Convert.ToDecimal(SqlHelper.ExecuteScalar(trans, CommandType.Text, strcssql2).ToString());

                        if (dtcs.Rows.Count == 0)
                        {
                            throw new Exception(pcl.cnvcInvCode + "无库存");
                        }
                        if (davaquantity - pcl.cnnAssignCount * dchangerate_st / dchangerate < 0)
                        {
                            throw new Exception(pcl.cnvcInvCode + "库存不足");
                        }

//						if(cs.cnnAvaQuantity - pcl.cnnAssignCount<0)
//							throw new Exception(pcl.cnvcInvCode+"库存不足");
                        decimal dhave = 0;
                        foreach (DataRow drcs in dtcs.Rows)
                        {
                            Entity.CurrentStock cs = new CurrentStock(drcs);
//							if(cs.cnnAvaQuantity - pcl.cnnAssignCount<0)
//								throw new Exception(pcl.cnvcInvCode+"库存不足");
//							cs.cnnAvaQuantity = cs.cnnAvaQuantity - pcl.cnnAssignCount;
//							cs.cnnQuantity = cs.cnnQuantity - pcl.cnnAssignCount;
//							EntityMapping.Update(cs,trans);


                            if (cs.cnnAvaQuantity > pcl.cnnAssignCount * dchangerate_st / dchangerate - dhave)
                            {
                                cs.cnnAvaQuantity = cs.cnnAvaQuantity - pcl.cnnAssignCount * dchangerate_st / dchangerate;
                                cs.cnnQuantity    = cs.cnnQuantity - pcl.cnnAssignCount * dchangerate_st / dchangerate;
                                EntityMapping.Update(cs, trans);
                                break;
                            }
                            else
                            {
                                cs.cnnAvaQuantity = 0;
                                cs.cnnQuantity    = 0;
                                EntityMapping.Update(cs, trans);
                                dhave += cs.cnnAvaQuantity;
                            }
                        }
                        rrd.cnnQuantity = pcl.cnnAssignCount * dchangerate_st / dchangerate;
                        EntityMapping.Create(rrd, trans);
                    }


                    //string strsql = "update tbMakeDetail set cnbCollar=1 where cnnMakeSerialNo="+strMakeSerialNo;
                    //SqlHelper.ExecuteNonQuery(trans,CommandType.Text,strsql);

                    string strsql4 = "update tbproducelog set cnvcproducestate='7' where cnnproduceserialno=" + strProduceSerialNo;
                    SqlHelper.ExecuteNonQuery(trans, CommandType.Text, strsql4);

                    operLog.cndOperDate  = dtSysTime;
                    operLog.cnvcComments = "生产流水:" + strProduceSerialNo;
                    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);
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 销售出库:保存单据
        /// </summary>
        /// <param name="user">操作员</param>
        /// <param name="rdRecord"></param>
        /// <param name="errMsg"></param>
        /// <returns></returns>
        /// <remarks>tianzhenyun 2013-06-26</remarks>
        public bool Save(User user, RdRecord rdRecord, out string errMsg)
        {
            //log message
            string logMsg = string.Format("操作员:{0},业务号:{1} ", user.UserName, rdRecord.cBusCode);

            errMsg = string.Empty;
            int  result;
            bool flag = false;
            //创建数据对象
            SqlConnection  conn = new SqlConnection(user.ConnectionString);
            SqlCommand     comm = new SqlCommand();
            SqlDataAdapter adp  = new SqlDataAdapter();

            //打开连接
            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                return(flag);
            }
            //开始事务
            SqlTransaction tran = conn.BeginTransaction();

            comm.Connection  = conn;
            comm.Transaction = tran;

            string strSql = string.Empty;

            try
            {
                //操作时间
                DateTime  now = rdRecord.dDate;
                DataTable dt  = new DataTable();

                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("开始生成销售出库单!--{0}", logMsg));
                }
                //单据类型编码及名称
                string cVouchType = "";//VouchType字典表
                string cVouchName = "销售出库单";
                comm.CommandText = string.Format("select cvouchtype from vouchtype where cvouchname='{0}'", cVouchName);
                cVouchType       = comm.ExecuteScalar().ToString();

                //单据类型编码、模板编号
                string cardNumber;
                int    vt_id;
                strSql            = string.Format("select def_id,cardnumber from Vouchers where ccardname='{0}'", cVouchName);
                comm.CommandText  = strSql;
                adp.SelectCommand = comm;
                adp.Fill(dt);
                if (dt.Rows.Count == 0)
                {
                    tran.Rollback();
                    errMsg = "单据类型编码、模板编号查询失败";
                    return(flag);
                }
                cardNumber = Cast.ToString(dt.Rows[0]["cardnumber"]);
                vt_id      = Cast.ToInteger(dt.Rows[0]["def_id"]);
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("单据类型编码:{0},模板号:{1}!", cardNumber, vt_id));
                }

                //RdRecord,RdRecords 数据表ID
                int id, autoid;
                comm.CommandText  = string.Format("select ifatherid,ichildid from UFSystem..UA_Identity where cVouchType ='rd' and cAcc_Id='{0}'", user.AccID);
                adp.SelectCommand = comm;
                dt = new DataTable();
                adp.Fill(dt);
                if (dt.Rows.Count == 0)
                {
                    tran.Rollback();
                    errMsg = "查询UA_Identity数据失败!";
                    return(flag);
                }
                id     = Cast.ToInteger(dt.Rows[0]["ifatherid"]);
                autoid = Cast.ToInteger(dt.Rows[0]["ichildid"]);

                //插入主表
                id++;//主表ID加1
                strSql = string.Format(@"INSERT INTO rdrecord (id,brdflag,cvouchtype,cbustype,csource,cbuscode,cwhcode,ddate,ccode,crdcode,cdepcode,cpersoncode,cstcode,ccuscode,cdlcode,cmaker,cdefine1,cdefine2,vt_id,iarriveid,iswfcontrolled,dnmaketime,dnverifytime,cHandler ,dVeriDate,cBillCode,isalebillid )
VALUES(@id,@brdflag,@cvouchtype,@cbustype,@csource,@cbuscode,@cwhcode,@ddate,@ccode,@crdcode,@cdepcode,@cpersoncode,@cstcode,@ccuscode,@cdlcode,@cmaker,@cdefine1,@cdefine2,@vt_id,@iarriveid,@iswfcontrolled,@dnmaketime,@dnverifytime,@cHandler ,@dVeriDate,@cBillCode,@isalebillid );");
                SqlParameter[] parms =
                {
                    new SqlParameter("@id",             SqlDbType.Int),          //收发记录主表标识
                    new SqlParameter("@brdflag",        SqlDbType.Bit),          //收发标志
                    new SqlParameter("@cvouchtype",     SqlDbType.VarChar, 2),   //单据类型编码
                    new SqlParameter("@cbustype",       SqlDbType.NVarChar, 12), //业务类型
                    new SqlParameter("@csource",        SqlDbType.NVarChar, 50), //单据来源
                    new SqlParameter("@cbuscode",       SqlDbType.VarChar, 30),  //对应业务单号
                    new SqlParameter("@cwhcode",        SqlDbType.VarChar, 10),  //仓库编码
                    new SqlParameter("@ddate",          SqlDbType.DateTime),     //单据日期
                    new SqlParameter("@ccode",          SqlDbType.VarChar, 30),  //收发单据号
                    new SqlParameter("@crdcode",        SqlDbType.VarChar, 5),   //收发类别编码
                    new SqlParameter("@cdepcode",       SqlDbType.VarChar, 12),  //部门编码
                    new SqlParameter("@cpersoncode",    SqlDbType.VarChar, 20),  //业务员编码
                    new SqlParameter("@cstcode",        SqlDbType.VarChar, 2),   //销售类型编码
                    new SqlParameter("@ccuscode",       SqlDbType.VarChar, 20),  //客户编码
                    new SqlParameter("@cdlcode",        SqlDbType.Int),          //发货退货单主表标识
                    new SqlParameter("@cmaker",         SqlDbType.NVarChar, 20), //制单人
                    new SqlParameter("@cdefine1",       SqlDbType.NVarChar, 20), //自定义项1
                    new SqlParameter("@cdefine2",       SqlDbType.NVarChar, 20), //自定义项2
                    new SqlParameter("@vt_id",          SqlDbType.Int),          //单据模版号
                    new SqlParameter("@iarriveid",      SqlDbType.VarChar, 30),  //发货退货单号
                    new SqlParameter("@iswfcontrolled", SqlDbType.Int),          //是否工作流控制
                    new SqlParameter("@dnmaketime",     SqlDbType.DateTime),     //制单时间
                    new SqlParameter("@dnverifytime",   SqlDbType.DateTime),     //审核时间
                    new SqlParameter("@cHandler",       SqlDbType.NVarChar, 20), //审核人
                    new SqlParameter("@dVeriDate",      SqlDbType.DateTime),     //审核日期
                    new SqlParameter("@cBillCode",      SqlDbType.Int),          //发票主表标识
                    new SqlParameter("@isalebillid",    SqlDbType.VarChar, 30)   //发票号
                };
                parms[0].Value  = id;
                parms[1].Value  = 0;//出
                parms[2].Value  = cVouchType;
                parms[3].Value  = rdRecord.cBusType;
                parms[4].Value  = rdRecord.cSource;
                parms[5].Value  = rdRecord.cBusCode;
                parms[6].Value  = rdRecord.List[0].cWhCode;
                parms[7].Value  = Convert.ToDateTime(now.ToShortDateString());
                parms[8].Value  = id.ToString();//后面作修改 //rdRecord.cCode;
                parms[9].Value  = rdRecord.cRdCode;
                parms[10].Value = rdRecord.cDepCode;
                parms[11].Value = string.IsNullOrEmpty(rdRecord.cPersonCode) ? DBNull.Value : (object)rdRecord.cPersonCode;
                parms[12].Value = rdRecord.cSTCode;
                parms[13].Value = rdRecord.cCusCode;
                parms[14].Value = rdRecord.DLID;
                parms[15].Value = user.UserName;
                parms[16].Value = rdRecord.cDefine1;
                parms[17].Value = rdRecord.cDefine2;
                parms[18].Value = vt_id;
                parms[19].Value = rdRecord.iarriveid;
                parms[20].Value = rdRecord.iswfcontrolled;
                parms[21].Value = now;
                parms[22].Value = now;
                parms[23].Value = user.UserName;
                parms[24].Value = Convert.ToDateTime(now.ToShortDateString());
                parms[25].Value = rdRecord.cBillCode == 0 ? DBNull.Value : (object)rdRecord.cBillCode;
                parms[26].Value = string.IsNullOrEmpty(rdRecord.isalebillid) ? DBNull.Value : (object)rdRecord.isalebillid;

                comm.CommandText = strSql;
                comm.Parameters.AddRange(parms);//添加参数
                if (comm.ExecuteNonQuery() < 1)
                {
                    tran.Rollback();
                    errMsg = "主表数据插入失败!";
                    return(flag);
                }
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("销售出库单RdRecord主表插入完成,主表ID:{0}!", id));
                }
                //清空命令中的参数
                comm.Parameters.Clear();
                strSql           = "if exists (select 1 from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#Ufida_WBBuffers') and type='U') drop table #Ufida_WBBuffers;";
                comm.CommandText = strSql;
                comm.ExecuteNonQuery();

                strSql           = "select a.id,autoid ,convert(decimal(30,2),iquantity) as iquantity,convert(decimal(30,2),inum) as iNum, a.Cinvcode,Corufts ,idlsid,iCheckIds, convert(smallint,0) as iOperate into #Ufida_WBBuffers from rdrecords a where 1=0";
                comm.CommandText = strSql;
                int i = comm.ExecuteNonQuery();

                strSql           = string.Format("update rdrecords set corufts ='' where id ={0}", id);
                comm.CommandText = strSql;
                comm.ExecuteNonQuery();


                //循环插入子表
                foreach (RdRecords rds in rdRecord.List)
                {
                    autoid++;
                    strSql = string.Format(@"Insert Into rdrecords(autoid,id,cinvcode,iquantity,iunitcost,iprice,cbatch,isoutquantity,dvdate,cposition,idlsid,isbsid,iensid,cbarcode,inquantity,dmadedate,imassdate,icheckids,cbvencode,cinvouchcode,bgsp,cgspstate,cmassunit,irefundinspectflag,iorderdid,bchecked,iordertype,bcosting,iinvexchrate,cbdlcode,iordercode,iexpiratdatecalcu,cexpirationdate,dexpirationdate,isotype,iorderseq)
VALUES(@autoid,@id,@cinvcode,@iquantity,@iunitcost,@iprice,@cbatch,@isoutquantity,@dvdate,@cposition,@idlsid,@isbsid,@iensid,@cbarcode,@inquantity,@dmadedate,@imassdate,@icheckids,@cbvencode,@cinvouchcode,@bgsp,@cgspstate,@cmassunit,@irefundinspectflag,@iorderdid,@bchecked,@iordertype,@bcosting,@iinvexchrate,@cbdlcode,@iordercode,@iexpiratdatecalcu,@cexpirationdate,@dexpirationdate,@isotype,@iorderseq);");
                    parms  = new SqlParameter[]
                    {
                        new SqlParameter("@autoid", SqlDbType.Int),
                        new SqlParameter("@id", SqlDbType.Int),
                        new SqlParameter("@cinvcode", SqlDbType.VarChar, 20),        //存货编码
                        new SqlParameter("@iquantity", SqlDbType.Float),             //数量
                        new SqlParameter("@iunitcost", SqlDbType.Float),             //单价
                        new SqlParameter("@iprice", SqlDbType.Money),                //金额
                        new SqlParameter("@cbatch", SqlDbType.VarChar, 30),          //批号
                        new SqlParameter("@isoutquantity", SqlDbType.Float),         //累计出库数量
                        new SqlParameter("@dvdate", SqlDbType.DateTime),             //失效日期
                        new SqlParameter("@cposition", SqlDbType.VarChar, 20),       //货位编码
                        new SqlParameter("@idlsid", SqlDbType.Int),                  //发货退货单子表标识
                        new SqlParameter("@isbsid", SqlDbType.Int),                  //发票子表标识
                        new SqlParameter("@iensid", SqlDbType.Int),                  //委托代销发货单子表标识
                        new SqlParameter("@cbarcode", SqlDbType.VarChar, 30),        //对应条形码编码
                        new SqlParameter("@inquantity", SqlDbType.Float),            //应收应发数量
                        new SqlParameter("@dmadedate", SqlDbType.DateTime),          //生产日期
                        new SqlParameter("@imassdate", SqlDbType.Int),               //保质期天数
                        new SqlParameter("@icheckids", SqlDbType.Int),               //检验单子表标识
                        new SqlParameter("@cbvencode", SqlDbType.VarChar, 20),       //供应商编码
                        new SqlParameter("@cinvouchcode", SqlDbType.VarChar, 30),    //对应入库单号
                        new SqlParameter("@bgsp", SqlDbType.Bit),                    //是否质检
                        new SqlParameter("@cgspstate", SqlDbType.VarChar, 20),       //质检状态
                        new SqlParameter("@cmassunit", SqlDbType.SmallInt),          //保质期单位
                        new SqlParameter("@irefundinspectflag", SqlDbType.Int),      //是否已经生成退货报检单1:生成,0:没有生成
                        new SqlParameter("@iorderdid", SqlDbType.Int),               //订单子表id
                        new SqlParameter("@bchecked", SqlDbType.Bit),                //销售出库单是否报检
                        new SqlParameter("@iordertype", SqlDbType.Int),              //订单类型
                        new SqlParameter("@bcosting", SqlDbType.Bit),                //单据是否核算
                        new SqlParameter("@iinvexchrate", SqlDbType.Decimal),        //换算率
                        new SqlParameter("@cbdlcode", SqlDbType.VarChar, 30),        //发货单号
                        new SqlParameter("@iordercode", SqlDbType.VarChar, 30),      //订单号
                        new SqlParameter("@iexpiratdatecalcu", SqlDbType.SmallInt),  //有效期推算方式
                        new SqlParameter("@cexpirationdate", SqlDbType.VarChar, 10), //有效期至
                        new SqlParameter("@dexpirationdate", SqlDbType.DateTime),    //有效期计算项
                        new SqlParameter("@isotype", SqlDbType.Int),                 //订单类型
                        new SqlParameter("@iorderseq", SqlDbType.Int)                //销售订单行号
                    };

                    //给参数赋值
                    parms[0].Value  = autoid;
                    parms[1].Value  = id;
                    parms[2].Value  = rds.cInvCode;
                    parms[3].Value  = rds.iScanQuantity;
                    parms[4].Value  = DBNull.Value; //rds.iUnitCost;目前没有使用
                    parms[5].Value  = DBNull.Value; //rds.iPrice;目前没有使用
                    parms[6].Value  = rds.cBatch;
                    parms[7].Value  = rds.iSOutQuantity;
                    parms[8].Value  = rds.dVDate == DateTime.MinValue ? DBNull.Value : (object)rds.dVDate;
                    parms[9].Value  = DBNull.Value;//rds.cPosition;
                    parms[10].Value = rds.iDLsID;
                    parms[11].Value = rds.iSBsID;
                    parms[12].Value = rds.iEnsID;
                    parms[13].Value = DBNull.Value;//rds.cBarCode;
                    parms[14].Value = rds.iNQuantity;
                    parms[15].Value = rds.dMadeDate == DateTime.MinValue ? DBNull.Value : (object)rds.dMadeDate;
                    parms[16].Value = rds.iMassDate;
                    parms[17].Value = DBNull.Value; //rds.iCheckIds;插入0导致客户U8无法删除单据
                    parms[18].Value = DBNull.Value; //rds.cBVencode;
                    parms[19].Value = DBNull.Value;
                    parms[20].Value = rds.bGsp;
                    parms[21].Value = DBNull.Value;//rds.cGspState;
                    parms[22].Value = rds.cMassUnit;
                    parms[23].Value = DBNull.Value;
                    parms[24].Value = rds.iorderdid;
                    parms[25].Value = DBNull.Value;
                    parms[26].Value = rds.iordertype;//没有查到数据
                    parms[27].Value = rds.bCosting;
                    parms[28].Value = rds.iInvExchRate;
                    parms[29].Value = rds.cbdlcode;
                    parms[30].Value = rds.iordercode;
                    parms[31].Value = rds.iExpiratDateCalcu;
                    parms[32].Value = string.IsNullOrEmpty(rds.cExpirationdate) ? DBNull.Value : (object)rds.cExpirationdate;
                    parms[33].Value = rds.dExpirationdate == DateTime.MinValue ? DBNull.Value : (object)rds.dExpirationdate;
                    parms[34].Value = rds.iSoType;
                    parms[35].Value = rds.iorderseq;

                    comm.CommandText = strSql;
                    comm.Parameters.Clear();
                    comm.Parameters.AddRange(parms);
                    if (comm.ExecuteNonQuery() < 1)
                    {
                        tran.Rollback();
                        errMsg = "子表数据插入失败";
                        return(flag);
                    }

                    strSql = string.Empty;
                    //插入标签流水号关系表
                    foreach (string number in rds.SerialList)
                    {
                        strSql += string.Format("INSERT INTO UFSystem..RdRecordSN( RDID, RDSID, cInvCode, cBatch, Number, AddDate )VALUES  ({0},{1},'{2}','{3}',{4},'{5}');", id, autoid, rds.cInvCode, rds.cBatch, number, now);
                    }
                    comm.CommandText = strSql;
                    if (comm.ExecuteNonQuery() < 1)
                    {
                        tran.Rollback();
                        errMsg = "标签流水号插入失败!";
                        return(flag);
                    }
                }
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("销售出库单RdRecords子表插入完成,共{0}条数据!", rdRecord.List.Count));
                }

                //清空命令中的参数
                comm.Parameters.Clear();

                #region 临时表处理

                strSql           = string.Format("Insert Into #Ufida_WBBuffers select a.id,autoid ,1 * convert (decimal(30,2),iquantity),1 * convert(decimal(30,2),inum), a.Cinvcode, Corufts  as Corufts, idlsid, iCheckIds,2 as iOperate   from rdrecords a  where id={0}", id);
                comm.CommandText = strSql;
                comm.ExecuteNonQuery();
                strSql           = @"if exists (select 1 from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#Ufida_WBBuffers_ST') and type='U') drop table #Ufida_WBBuffers_ST;
if exists (select 1 from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#Ufida_WBBuffers_Target') and type='U') drop table #Ufida_WBBuffers_Target;";
                comm.CommandText = strSql;
                comm.ExecuteNonQuery();

                strSql           = @"select max(id) as id,autoid,Sum(iquantity) as iquantity,sum(inum) as inum,max(cinvcode) as cinvcode ,Max(corufts) as corufts,  max(idlsid) as idlsid, sum(iOperate) as iOperate  into  #Ufida_WBBuffers_ST from #Ufida_WBBuffers group by autoid having (Sum(iquantity)<>0 or Sum(inum)<>0 );
update  #Ufida_WBBuffers_ST set corufts='' where iOperate<>2";
                comm.CommandText = strSql;
                comm.ExecuteNonQuery();

                strSql           = "select idlsid as idid,sum(iquantity) as iquantity,sum(inum) as inum,max(cinvcode) as cinvcode,Max(corufts) as corufts  into #Ufida_WBBuffers_Target from #Ufida_WBBuffers_ST group by idlsid ;";
                comm.CommandText = strSql;
                comm.ExecuteNonQuery();

                strSql           = "update dispatchlists with (UPDLOCK) set fOutQuantity=cast(isnull(fOutQuantity,0)+isnull(#Ufida_WBBuffers_Target.iquantity,0)  as decimal(30,2)), fOutNum=cast(isnull(fOutNum,0)+isnull(#Ufida_WBBuffers_Target.inum,0) as decimal(30,2)) from dispatchlists inner join #Ufida_WBBuffers_Target on dispatchlists.idlsid=#Ufida_WBBuffers_Target.idid where bsettleall=0";
                comm.CommandText = strSql;
                result           = comm.ExecuteNonQuery();
                if (result < 0)
                {
                    tran.Rollback();
                    errMsg = "dispatchlists fOutQuantity update error!";
                    return(flag);
                }
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("临时表处理,修改发货单子表的待发货数量,影响行数:{0}!", result));
                }

                /*
                 * 2013-11-14
                 * 此操作用来验证发货数量是否超过待发货数量
                 * (用于解决U8与终端同时操作同一个单据时出现两个相同的销售出库单)
                 * */
                strSql            = @"select * from 
(
	select 
		cast((case when isnull(a.iquantity,0) >0 then 1 when isnull(a.iquantity,0)<0 then -1 else 0 end )*(isnull(a.iquantity,0)-isnull(foutquantity,0)) as decimal(30,2)) as iquantity, 
		cast((case when isnull(a.inum,0)>0 then 1 when isnull(a.inum,0)<0 then -1 else 0 end)*(isnull(a.inum,0)-isnull(foutnum,0)) as decimal(30,2)) as inum,
		inventory.igrouptype ,inventory.cinvcode ,inventory.cinvname  
		from 
			(
				Select 
					case when isnull(bqaneedcheck ,0)=0 or isnull(iquantity,0) <0 then iquantity else iqaquantity end as iquantity,
					case when isnull(bqaneedcheck ,0)=0 or isnull(iquantity,0) <0 then inum else iqanum end as inum,
					foutquantity,foutnum,idlsid ,cinvcode  from dispatchlists
			) as a 
	inner join inventory on a.cinvcode=inventory.cinvcode 
	inner join #Ufida_WBBuffers_Target on a.idlsid=#Ufida_WBBuffers_Target.idid
)
temp where temp.iquantity<0 or temp.inum<0";
                comm.CommandText  = strSql;
                adp.SelectCommand = comm;
                dt = new DataTable();
                adp.Fill(dt);
                if (dt.Rows.Count > 0)//如果有数量说明,这些存货的数量超过了待发货数量
                {
                    errMsg = "此单据可能已生成出库单!\r\n";
                    foreach (DataRow row in dt.Rows)
                    {
                        errMsg += string.Format("名称:[{0}] 编号:[{1}] 此存货的发货数量超过了待发货数量!\r\n", row["cinvname"], row["cinvcode"]);
                    }
                    if (Common.flag)
                    {
                        Common.log.Error(errMsg);
                    }
                    tran.Rollback();//开始回滚
                    return(flag);
                }

                strSql           = "if exists (select 1 from tempdb.dbo.sysobjects where id = object_id(N'tempdb..#tmpdlid') and type='U') drop table #tmpdlid;";
                comm.CommandText = strSql;
                comm.ExecuteNonQuery();
                strSql           = "select distinct dlid into #tmpdlid from dispatchlists inner join #Ufida_WBBuffers_Target on dispatchlists.idlsid=#Ufida_WBBuffers_Target.idid";
                comm.CommandText = strSql;
                comm.ExecuteNonQuery();

                strSql           = "update dispatchlist  set cSaleOut=N'' from dispatchlist inner join #tmpdlid b on dispatchlist.dlid=b.dlid where isnull(cSaleOut,'')='' or isnull(cSaleOut,'')='ST' ";
                comm.CommandText = strSql;
                result           = comm.ExecuteNonQuery();
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("临时表处理,修改发货单主表的cSaleOut为‘’,影响行数:{0}!", result));
                }

                strSql           = "update dispatchlist  set cSaleOut=N'ST' from dispatchlist  inner join #tmpdlid b on dispatchlist.dlid=b.dlid inner join  dispatchlists c on c.dlid=dispatchlist.dlid inner join rdrecords on c.idlsid=rdrecords.idlsid  where isnull(cSaleOut,'')='' or isnull(cSaleOut,'')='ST' ";
                comm.CommandText = strSql;
                result           = comm.ExecuteNonQuery();
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("临时表处理,修改发货单主表的cSaleOut为‘ST’,影响行数:{0}!", result));
                }

                strSql           = @"
drop table #Ufida_WBBuffers;
drop table #Ufida_WBBuffers_ST;
drop table #Ufida_WBBuffers_Target;
drop table #tmpdlid;";
                comm.CommandText = strSql;
                comm.ExecuteNonQuery();

                #endregion

                //保存
                //strSql = string.Format("exec ST_SaveForStock N'{0}',N'{1}',1 ,0 ,1", cVouchType, id);
                //comm.CommandText = strSql;
                //result = comm.ExecuteNonQuery();

                //审核
                strSql           = string.Format("exec ST_VerForStock N'{0}',N'{1}',0,1,1", cVouchType, id);
                comm.CommandText = strSql;
                result           = comm.ExecuteNonQuery();
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("审核销售出库单,影响行数:{0}!", result));
                }


                strSql           = "select @@spid";
                comm.CommandText = strSql;
                string spid = comm.ExecuteScalar().ToString();
                if (string.IsNullOrEmpty(spid))
                {
                    tran.Rollback();
                    return(flag);
                }

                //strSql = "select transactionid,* from SCM_EntryLedgerBuffer";
                //dt = DBHelperSQL.QueryTable(user.ConnectionString, strSql);

                strSql           = string.Format(@"insert into SCM_Item(cInvCode,cfree1,cfree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8,cfree9,cfree10)
 select distinct cInvCode,cfree1,cfree2,cfree3,cfree4,cfree5,cfree6,cfree7,cfree8,cfree9,cfree10  from SCM_EntryLedgerBuffer a with (nolock) 
 where a.transactionid=N'spid_{0}' and not exists (select 1 from SCM_Item Item where Item.cInvCode=a.cInvCode and Item.cfree1=a.cfree1 
 and Item.cfree2=a.cfree2 and Item.cfree3=a.cfree3 and Item.cfree4=a.cfree4 and Item.cfree5=a.cfree5 
 and Item.cfree6=a.cfree6 and Item.cfree7=a.cfree7 and Item.cfree8=a.cfree8 and Item.cfree9=a.cfree9 and Item.cfree10=a.cfree10  )", spid);
                comm.CommandText = strSql;
                result           = comm.ExecuteNonQuery();
                strSql           = string.Format("exec Usp_SCM_CommitGeneralLedgerWithCheck N'ST',1,1,1,1,0,0,1,1,1,0,0,0,1,'spid_{0}'", spid);
                comm.CommandText = strSql;
                result           = comm.ExecuteNonQuery();
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("执行Usp_SCM_CommitGeneralLedgerWithCheck存储过程,影响行数:{0}!", result));
                }


                //单据号处理
                //voucherhistory
                strSql           = string.Format("select cNumber as Maxnumber From VoucherHistory  with (NOLOCK) Where  CardNumber='{0}' and cContent is NULL", cardNumber);
                comm.CommandText = strSql;
                object obj = comm.ExecuteScalar();
                int    cNumber;
                if (obj == null || obj == DBNull.Value)
                {
                    cNumber = 1;
                    strSql  = string.Format("INSERT INTO dbo.VoucherHistory( CardNumber ,iRdFlagSeed ,cContent ,cContentRule ,cSeed ,cNumber ,bEmpty) VALUES({0},NULL,NULL,NULL,NULL,{1},0);", cardNumber, cNumber);
                }
                else
                {
                    cNumber = Cast.ToInteger(obj) + 1;
                    strSql  = string.Format("update VoucherHistory set cNumber='{0}' Where  CardNumber='{1}' and cContent is NULL", cNumber, cardNumber);
                }
                comm.CommandText = strSql;
                result           = comm.ExecuteNonQuery();
                if (result < 1)
                {
                    tran.Rollback();
                    errMsg = "update voucherhistory error!";
                    return(flag);
                }
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("处理VoucherHistory表的单据号,影响行数:{0}!", result));
                }


                //RdRecord
                string cCode = string.Format("{0}{1}", now.ToString("yyyy"), cNumber.ToString().PadLeft(8, '0'));
                strSql           = string.Format("Select cCode  from RdRecord with (nolock) Where cCode=N'{0}' and id<>{1} AND cVouchType=N'{2}'", cCode, id, cVouchType);
                comm.CommandText = strSql;
                if (comm.ExecuteScalar() != null)
                {
                    tran.Rollback();
                    errMsg = "单据号重复!";
                    return(flag);
                }
                strSql           = string.Format("Update RdRecord Set cCode = N'{0}' Where Id = {1}", cCode, id);
                comm.CommandText = strSql;
                result           = comm.ExecuteNonQuery();
                if (result < 1)
                {
                    tran.Rollback();
                    errMsg = "RdRecord表更新出错";
                    return(flag);
                }
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("修改销售出库单主表的cCode字段为{0},影响行数:{1}!", cCode, result));
                }


                //UA_identity
                strSql           = string.Format("UPDATE UFSystem..UA_Identity SET iFatherId={0},iChildId={1} WHERE cVouchType='rd' AND cAcc_Id='{2}'", id, autoid, user.AccID);
                comm.CommandText = strSql;
                result           = comm.ExecuteNonQuery();
                if (result < 0)
                {
                    tran.Rollback();
                    errMsg = "UA_Identity更新出错";
                    return(flag);
                }
                tran.Commit();
                flag = true;
                //log
                if (Common.flag)
                {
                    Common.log.Info(string.Format("销售出库单生成完成!"));
                }
            }
            catch (Exception ex)
            {
                errMsg = ex.Message;
                tran.Rollback();
            }
            finally
            {
                conn.Close();
            }
            return(flag);
        }
Ejemplo n.º 8
0
        private void btnCheck_Click(object sender, System.EventArgs e)
        {
            if (Session["tbProduceDetail"] == null)
            {
                this.Popup("请首先使用【盘点清单】按钮,查询计划情况");
                return;
            }
            if (this.JudgeIsNull(txtDays.Text))
            {
                this.Popup("请输入过期天数调整量");
                return;
            }
            DataTable dtpd = (DataTable)Session["tbProduceDetail"];

            ArrayList al             = new ArrayList();
            DataTable dtInv          = Application["tbInventory"] as DataTable;
            DataTable dtProductClass = Application["tbProductClass"] as DataTable;

//			string strSql = "select * from tbProduceCheckLog where cnnProduceSerialNo=" + txtProduceSerialNo.Text+" order by cnvcInvCode";
//			DataTable dtCheck = Helper.Query(strSql);

            //foreach(DataGridItem dgi in this.DataGrid1.Items)
            foreach (DataRow dr in dtpd.Rows)
            {
                //Entity.ProduceCheckLog pc = new ProduceCheckLog(dr);

                string strinvcode = dr["cnvcInvCode"].ToString();               //dgi.Cells[0].Text;
                string strinvname = dr["cnvcInvName"].ToString();               //dgi.Cells[1].Text;
                string strincount = dr["cnnInCount"].ToString();                //dgi.Cells[6].Text;
                //string strwhcount = dgi.Cells[7].Text;
                bool iswh = Convert.ToBoolean(dr["cnbInWh"].ToString());        //((CheckBox)dgi.Cells[7].Controls[1]).Checked;
                if (iswh)
                {
                    this.Popup("已经完成了盘点入库");
                    return;
                }
                decimal dincount          = Convert.ToDecimal(strincount);
                Entity.RdRecordDetail rrd = new RdRecordDetail();
                rrd.cnvcInvCode = strinvcode;
                rrd.cnnQuantity = Convert.ToDecimal(strincount);
                DataRow[] drInvs = dtInv.Select("cnvcInvCode='" + strinvcode + "'");
                if (drInvs.Length == 0)
                {
                    this.Popup(strinvname + "存货档案未找到");
                    return;
                }
                Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory(drInvs[0]);

                DataRow[] drProductClasses = dtProductClass.Select("cnvcProductClassCode='" + inv.cnvcInvCCode + "'");
                if (drProductClasses.Length == 0)
                {
                    this.Popup(strinvname + "的存货类别未找到");
                    return;
                }
                Entity.ProductClass pc = new ProductClass(drProductClasses[0]);

                rrd.cnvcGroupCode   = inv.cnvcGroupCode;
                rrd.cnvcComunitCode = inv.cnvcSTComUnitCode;
                rrd.cnvcFlag        = "0";
                rrd.cndExpDate      = Convert.ToDateTime(this.txtProduceDate.Text).AddDays(pc.cnnDays).AddDays(Convert.ToDouble(txtDays.Text));           //Convert.ToDateTime(this.txtExpDate.Text);
                rrd.cndMdate        = Convert.ToDateTime(this.txtProduceDate.Text);

                //if(rrd.cnnQuantity == 0)continue;
                al.Add(rrd);
            }

            if (al.Count == 0)
            {
                this.Popup("无入库产品,不用生产入库!");
                return;
            }
            Entity.RdRecord rr = new RdRecord();
            rr.cnvcRdCode    = "RD009";
            rr.cnvcRdFlag    = "0";
            rr.cnvcWhCode    = this.ddlWarehouse.SelectedValue;
            rr.cnvcDepID     = this.ddlProduceDept.SelectedValue;
            rr.cnvcOperName  = this.oper.strOperName;
            rr.cnvcComments  = "生产入库";
            rr.cnvcMaker     = this.oper.strLoginID;
            rr.cnnProorderID = Convert.ToDecimal(this.txtProduceSerialNo.Text);
            rr.cnvcState     = "2";

            OperLog ol = new OperLog();

            ol.cnvcOperID   = this.oper.strLoginID;
            ol.cnvcDeptID   = this.oper.strDeptID;
            ol.cnvcOperType = "生产入库";
            string strWarehouse = this.ddlWarehouse.SelectedValue;

            try
            {
                ProduceFacade pf = new ProduceFacade();
                pf.CheckInWh(this.txtMakeSerialNo.Text, rr, al, ol, strWarehouse);
                this.Popup("生产入库成功");
            }
            catch (Exception ex)
            {
                this.Popup(ex.Message);
            }
            QueryProduceDetail();
            BindGrid();
        }
Ejemplo n.º 9
0
        private void btAdd_Click(object sender, System.EventArgs e)
        {
            strOutArriveDate = Request.Form["txtOutArvDate"].ToString();
            if (strOutArriveDate == "" || strOutArriveDate == null)
            {
                this.Popup("出库时间不能为空,请重新选择时间!");
                return;
            }
            strInArriveDate = Request.Form["txtInArvDate"].ToString();
            if (strInArriveDate == "" || strInArriveDate == null)
            {
                this.Popup("入库时间不能为空,请重新选择时间!");
                return;
            }
            Entity.RdRecord rdout = new RdRecord();
            rdout.cnvcCode         = this.txtMoveCode.Text.Trim();
            rdout.cnvcRdCode       = "RD005";
            rdout.cnvcRdFlag       = "1";
            rdout.cnvcWhCode       = this.ddlOutWhouse.SelectedValue;
            rdout.cnvcDepID        = this.ddlOutDeptID.SelectedValue;
            rdout.cnvcWhpersonName = this.txtOutWHPerson.Text.Trim();
            rdout.cnvcOperName     = this.oper.strOperName;
            rdout.cnvcComments     = this.txtComments.Text.Trim();
            rdout.cnvcMaker        = this.oper.strOperName;
            rdout.cnvcShipAddress  = this.txtShipAddress.Text.Trim();
            rdout.cndARVDate       = DateTime.Parse(strOutArriveDate);
            rdout.cnvcARVAddress   = this.txtArvAddress.Text.Trim();
            rdout.cnvcState        = "0";

            Entity.RdRecord rdin = new RdRecord();
            rdin.cnvcCode         = this.txtMoveCode.Text.Trim();
            rdin.cnvcRdCode       = "RD006";
            rdin.cnvcRdFlag       = "0";
            rdin.cnvcWhCode       = this.ddlInWhouse.SelectedValue;
            rdin.cnvcDepID        = this.ddlInDeptID.SelectedValue;
            rdin.cnvcWhpersonName = this.txtInWHPerson.Text.Trim();
            rdin.cnvcOperName     = this.oper.strOperName;
            rdin.cnvcComments     = this.txtComments.Text.Trim();
            rdin.cnvcMaker        = this.oper.strOperName;
            rdin.cnvcShipAddress  = this.txtShipAddress.Text.Trim();
            rdin.cndARVDate       = DateTime.Parse(strInArriveDate);
            rdin.cnvcARVAddress   = this.txtArvAddress.Text.Trim();
            rdin.cnvcState        = "0";

            if (rdout.cnvcCode == "" || rdout.cnvcCode.Length != 13 || rdin.cnvcCode == "" || rdin.cnvcCode.Length != 13)
            {
                this.Popup("调拨单号不正确!");
                return;
            }
            if (rdout.cnvcDepID == "" || rdout.cnvcWhCode == "")
            {
                this.Popup("出库部门或仓库不能为空!");
                return;
            }
            if (rdin.cnvcDepID == "" || rdin.cnvcWhCode == "")
            {
                this.Popup("出库部门或仓库不能为空!");
                return;
            }
            if (rdout.cnvcWhCode == rdin.cnvcWhCode)
            {
                this.Popup("同一仓库不能调拨!");
                return;
            }

            Entity.OperLog ol = new AMSApp.zhenghua.Entity.OperLog();
            ol.cnvcOperType = "添加调拨主单";
            ol.cnvcOperID   = this.oper.strLoginID;
            ol.cnvcDeptID   = this.oper.strDeptID;

            StorageFacade sto = new StorageFacade();
            int           ret = sto.AddRdRecordMove(ol, rdout, rdin);

            if (ret > 0)
            {
                this.Popup("添加调拨单内容成功!");
            }
            else
            {
                this.Popup("添加调拨单内容失败!");
            }
        }
        private void Button2_Click(object sender, System.EventArgs e)
        {
            //领料单打印
            ArrayList al    = new ArrayList();
            DataTable dtInv = Application["tbInventory"] as DataTable;

            foreach (DataGridItem dgi in this.DataGrid1.Items)
            {
                string strinvcode  = dgi.Cells[0].Text;
                string strinvname  = dgi.Cells[1].Text;
                string stroutcount = dgi.Cells[6].Text;
                string strwhcount  = dgi.Cells[7].Text;
                bool   iscollar    = ((CheckBox)dgi.Cells[8].Controls[1]).Checked;
                if (iscollar)
                {
                    //this.Popup(strinvname+"已经完成了生产材料领用");
                    this.Popup("已经领用生产材料");
                    return;
                }

                if (!this.JudgeIsNum(strwhcount))
                {
                    this.Popup(strinvname + "无库存,不能领用原材料,请检查原材料库存");
                    return;
                }
                decimal doutcount = Convert.ToDecimal(stroutcount);
                decimal dwhcount  = Convert.ToDecimal(strwhcount);
                if (doutcount > dwhcount)
                {
                    this.Popup(strinvname + "库存数量不足,不能领用原材料进行生产,请检查原材料库存");
                    return;
                }
                Entity.RdRecordDetail rrd = new RdRecordDetail();
                rrd.cnvcInvCode = strinvcode;
                rrd.cnnQuantity = Convert.ToDecimal(stroutcount);
                DataRow[] drInvs = dtInv.Select("cnvcInvCode='" + strinvcode + "'");
                if (drInvs.Length == 0)
                {
                    this.Popup(strinvname + "存货档案未找到");
                    return;
                }
                Entity.Inventory inv = new AMSApp.zhenghua.Entity.Inventory(drInvs[0]);
                rrd.cnvcGroupCode   = inv.cnvcGroupCode;
                rrd.cnvcComunitCode = inv.cnvcSTComUnitCode;
                rrd.cnvcFlag        = "0";

                al.Add(rrd);
            }

            Entity.RdRecord rr = new RdRecord();
            rr.cnvcRdCode    = "RD008";
            rr.cnvcRdFlag    = "0";
            rr.cnvcWhCode    = this.ddlWarehouse.SelectedValue;
            rr.cnvcDepID     = this.ddlProduceDept.SelectedValue;
            rr.cnvcOperName  = this.oper.strOperName;
            rr.cnvcComments  = "生产材料领用";
            rr.cnvcMaker     = this.oper.strLoginID;
            rr.cnnProorderID = Convert.ToDecimal(this.txtProduceSerialNo.Text);
            rr.cnvcState     = "2";


            OperLog ol = new OperLog();

            ol.cnvcOperID   = this.oper.strLoginID;
            ol.cnvcDeptID   = this.oper.strDeptID;
            ol.cnvcOperType = "生产材料领用";

            string strWarehouse = this.ddlWarehouse.SelectedValue;

            try
            {
                ProduceFacade pf = new ProduceFacade();
                pf.Collar(this.txtMakeSerialNo.Text, rr, al, ol, strWarehouse);
                this.Popup("生产材料领用成功");
            }
            catch (Exception ex)
            {
                this.Popup(ex.Message);
            }
            BindGrid();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 把销售发货主表对象转换成销售出库主表对象
        /// </summary>
        /// <param name="dispatchList"></param>
        /// <returns></returns>
        public static RdRecord ConvertToRdrecord(DispatchList dispatchList)
        {
            RdRecord rdRecord = new RdRecord();

            //rdRecord.cVouchName = "销售出库单";//VouchType字典表
            //rdRecord.cVouchType = "32";
            rdRecord.cRdCode = "201";//数据表rd_style
            //rdRecord.cRdName = "销售出库";

            rdRecord.cWhCode = dispatchList.cWhCode;
            rdRecord.cWhName = dispatchList.cWhName;
            //rdRecord.bIsSTQc = dispatchList.bIsSTQc;
            //rdRecord.bRdFlag = dispatchList.bRdFlag;
            rdRecord.cAccounter  = dispatchList.cAccounter;
            rdRecord.cAddCode    = dispatchList.caddcode;
            rdRecord.cBillCode   = dispatchList.SBVID;    //发票主表标识
            rdRecord.isalebillid = dispatchList.cSBVCode; //发票号
            //来源单据:判断发票号是否空,如果为空则为发货单号,否则为发票号(即零售日报号)
            rdRecord.cBusCode = string.IsNullOrEmpty(dispatchList.cSBVCode) ? dispatchList.cDLCode : dispatchList.cSBVCode;
            rdRecord.cBusType = dispatchList.cBusType;
            //rdRecord.cChkCode = dispatchList.cchkcode;
            //rdRecord.cChkPerson = dispatchList.cchkperson;
            //rdRecord.cCode = dispatchList;
            rdRecord.cContactName = dispatchList.cContactName;
            rdRecord.cCusAbbName  = dispatchList.cCusAbbName;
            //rdRecord.ccusaddress = dispatchList.ccusaddress;
            rdRecord.cCusCode = dispatchList.cCusCode;
            //rdRecord.ccushand = dispatchList.ccushand;
            rdRecord.ccusperson = dispatchList.ccusperson;
            //rdRecord.ccusphone = dispatchList.ccusphone;
            rdRecord.cDefine1     = dispatchList.cDefine1;
            rdRecord.cDefine2     = dispatchList.cDefine2;
            rdRecord.cDefine3     = dispatchList.cDefine3;
            rdRecord.cDefine4     = dispatchList.cDefine4;
            rdRecord.cDefine5     = dispatchList.cDefine5;
            rdRecord.cDefine6     = dispatchList.cDefine6;
            rdRecord.cDefine7     = dispatchList.cDefine7;
            rdRecord.cDefine8     = dispatchList.cDefine8;
            rdRecord.cDefine9     = dispatchList.cDefine9;
            rdRecord.cDefine10    = dispatchList.cDefine10;
            rdRecord.cDefine11    = dispatchList.cDefine11;
            rdRecord.cDefine12    = dispatchList.cDefine12;
            rdRecord.cDefine13    = dispatchList.cDefine13;
            rdRecord.cDefine14    = dispatchList.cDefine14;
            rdRecord.cDefine15    = dispatchList.cDefine15;
            rdRecord.cDefine16    = dispatchList.cDefine16;
            rdRecord.cdeliverunit = dispatchList.cdeliverunit;
            rdRecord.cDepCode     = dispatchList.cDepCode;
            rdRecord.cDepName     = dispatchList.cDepName;
            rdRecord.DLID         = dispatchList.DLID;
            rdRecord.cDLCode      = dispatchList.cDLCode;
            //rdRecord.cHandler = dispatchList.chandler;
            //rdRecord.cMaker = dispatchList.cMaker;
            rdRecord.cMemo        = dispatchList.cMemo;
            rdRecord.cmobilephone = dispatchList.cmobilephone;
            //rdRecord.cModifyPerson = dispatchList.cmodifier;
            rdRecord.cofficephone = dispatchList.cofficephone;
            //rdRecord.contactmobile = dispatchList.contactmobile;
            //rdRecord.contactphone = dispatchList.contactphone;
            rdRecord.cPersonCode = dispatchList.cPersonCode;
            rdRecord.cPersonName = dispatchList.cPersonName;
            //rdRecord.cRdCode = dispatchList.cRdCode;
            //rdRecord.cRdName = dispatchList.cRdName;
            rdRecord.cShipAddress = dispatchList.cShipAddress;
            rdRecord.cSource      = dispatchList.cVouchName;
            rdRecord.cSTCode      = dispatchList.cSTCode;
            rdRecord.cSTName      = dispatchList.cSTName;
            //rdRecord.cVenAbbName = dispatchList.;
            //rdRecord.cVenCode = dispatchList.cvencode;
            //rdRecord.cWhName = dispatchList.cwhname;
            //rdRecord.dChkDate = dispatchList.dchkdate;
            //rdRecord.dDate = MainForm.OperateTime; //单据日期
            //rdRecord.dModifyDate = dispatchList.dmoddate;
            //rdRecord.dnmaketime =DateTime.Now;// dispatchList;
            //rdRecord.dnmodifytime = dispatchList.dmodifysystime;
            //rdRecord.dnverifytime = dispatchList.dverifysystime;
            //rdRecord.dVeriDate = dispatchList.dverifydate;
            //rdRecord.gspcheck = dispatchList.;
            rdRecord.iarriveid = dispatchList.cDLCode;//发货退货单号
            //rdRecord.iAvaNum = dispatchList.iav;
            //rdRecord.iAvaQuantity = dispatchList.iav;
            //rdRecord.ID=;
            //rdRecord.iLowSum = dispatchList.;
            //rdRecord.ipresent = dispatchList.ipr;
            //rdRecord.iPresentNum = dispatchList.ipr;
            //rdRecord.ireturncount = dispatchList.ireturncount;
            //rdRecord.iSafeSum =;
            rdRecord.iswfcontrolled = dispatchList.iswfcontrolled;
            //rdRecord.iTopSum=;
            //rdRecord.iverifystate = dispatchList.iverifystate;
            //rdRecord.iVTid = ;
            rdRecord.ufts = dispatchList.ufts;

            return(rdRecord);
        }
Ejemplo n.º 12
0
 public bool ST_SaleOut_Save(User user, RdRecord rdRecord, out string errMsg)
 {
     return(new DAL.SaleOut().Save(user, rdRecord, out errMsg));
 }