Esempio n. 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(BCheckBillData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append("insert into BCheckBill(");
            strSql.Append(@"checkBillNo,arriveBillNo,financeBillNo,materialNo,checkResult,checkMark,checkEmpId,checkDt,isrtEmpId,isrtDt,
                            updtEmpId,updtDt,commitEmpId,commitDt,instantState)");
            strSql.Append(" values (");
            strSql.Append(@"@checkBillNo,@arriveBillNo,@financeBillNo,@materialNo,@checkResult,@checkMark,@checkEmpId,@checkDt,@isrtEmpId,@isrtDt,
                            @updtEmpId,@updtDt,@commitEmpId,@commitDt,@instantState)");
            strSql.Append("; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@checkBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@checkResult", SqlDbType.NVarChar,20),
                    new SqlParameter("@checkMark", SqlDbType.NVarChar,200),
                    new SqlParameter("@checkEmpId", SqlDbType.Int),
                    new SqlParameter("@checkDt", SqlDbType.DateTime),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime),
                    new SqlParameter("@commitEmpId", SqlDbType.Int),
                    new SqlParameter("@commitDt", SqlDbType.DateTime),
                    new SqlParameter("@instantState", SqlDbType.NVarChar,20)
                };
            parameters[0].Value = model.checkBillNo;
            parameters[1].Value = model.arriveBillNo;
            parameters[2].Value = model.financeBillNo;
            parameters[3].Value = model.materialNo;
            parameters[4].Value = model.checkResult;
            parameters[5].Value = model.checkMark;
            parameters[6].Value = model.checkEmpId;
            parameters[7].Value = model.checkDt == string.Empty ? null : model.checkDt;
            parameters[8].Value = model.isrtEmpId;
            parameters[9].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[10].Value = model.updtEmpId;
            parameters[11].Value = model.updtDt == string.Empty ? null : model.updtDt;
            parameters[12].Value = model.commitEmpId;
            parameters[13].Value = model.commitDt == string.Empty ? null : model.commitDt;
            parameters[14].Value = model.instantState;

            int id = 0;
            try
            {
                object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

                if (ret != null && ret != DBNull.Value)
                {
                    id = Convert.ToInt32(ret);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return id;
        }
Esempio n. 2
0
        /// <summary>
        /// 得到一个model
        /// </summary>
        /// <param name="id">主键值</param>
        /// <returns>model</returns>
        public BCheckBillData GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"select id,checkBillNo,arriveBillNo,financeBillNo,materialNo,checkResult,checkMark,checkEmpId,checkDt,isrtEmpId,isrtDt,
                            updtEmpId,updtDt,commitEmpId,commitDt,instantState from BCheckBill");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int)
                };
            parameters[0].Value = id;

            BCheckBillData model = new BCheckBillData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["id"] != DBNull.Value)
                {
                    model.id = Convert.ToInt32(row["id"]);
                }
                if (row["checkBillNo"] != DBNull.Value)
                {
                    model.checkBillNo = Convert.ToString(row["checkBillNo"]);
                }
                if (row["arriveBillNo"] != DBNull.Value)
                {
                    model.arriveBillNo = Convert.ToString(row["arriveBillNo"]);
                }
                if (row["financeBillNo"] != DBNull.Value)
                {
                    model.financeBillNo = Convert.ToString(row["financeBillNo"]);
                }
                if (row["materialNo"] != DBNull.Value)
                {
                    model.materialNo = Convert.ToString(row["materialNo"]);
                }
                if (row["checkResult"] != DBNull.Value)
                {
                    model.checkResult = Convert.ToString(row["checkResult"]);
                }
                if (row["checkMark"] != DBNull.Value)
                {
                    model.checkMark = Convert.ToString(row["checkMark"]);
                }
                if (row["checkEmpId"] != DBNull.Value)
                {
                    model.checkEmpId = Convert.ToInt32(row["checkEmpId"]);
                }
                if (row["checkDt"] != DBNull.Value)
                {
                    model.checkDt = Convert.ToString(row["checkDt"]);
                }
                if (row["isrtEmpId"] != DBNull.Value)
                {
                    model.isrtEmpId = Convert.ToInt32(row["isrtEmpId"]);
                }
                if (row["isrtDt"] != DBNull.Value)
                {
                    model.isrtDt = Convert.ToString(row["isrtDt"]);
                }
                if (row["updtEmpId"] != DBNull.Value)
                {
                    model.updtEmpId = Convert.ToInt32(row["updtEmpId"]);
                }
                if (row["updtDt"] != DBNull.Value)
                {
                    model.updtDt = Convert.ToString(row["updtDt"]);
                }
                if (row["commitEmpId"] != DBNull.Value)
                {
                    model.commitEmpId = Convert.ToInt32(row["commitEmpId"]);
                }
                if (row["commitDt"] != DBNull.Value)
                {
                    model.commitDt = Convert.ToString(row["commitDt"]);
                }
                if (row["instantState"] != DBNull.Value)
                {
                    model.instantState = Convert.ToString(row["instantState"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(BCheckBillData model)
        {
            bool ret = false;
            StringBuilder strSql = new StringBuilder();
            strSql.Append("update BCheckBill set ");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected],");
            strSql.Append("[email protected]");
            strSql.Append(" where id = @id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int),
                    new SqlParameter("@checkBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@arriveBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@financeBillNo", SqlDbType.VarChar,20),
                    new SqlParameter("@materialNo", SqlDbType.VarChar,20),
                    new SqlParameter("@checkResult", SqlDbType.NVarChar,20),
                    new SqlParameter("@checkMark", SqlDbType.NVarChar,200),
                    new SqlParameter("@checkEmpId", SqlDbType.Int),
                    new SqlParameter("@checkDt", SqlDbType.DateTime),
                    new SqlParameter("@isrtEmpId", SqlDbType.Int),
                    new SqlParameter("@isrtDt", SqlDbType.DateTime),
                    new SqlParameter("@updtEmpId", SqlDbType.Int),
                    new SqlParameter("@updtDt", SqlDbType.DateTime),
                    new SqlParameter("@commitEmpId", SqlDbType.Int),
                    new SqlParameter("@commitDt", SqlDbType.DateTime),
                    new SqlParameter("@instantState", SqlDbType.NVarChar,20)
                };
            parameters[0].Value = model.id;
            parameters[1].Value = model.checkBillNo;
            parameters[2].Value = model.arriveBillNo;
            parameters[3].Value = model.financeBillNo;
            parameters[4].Value = model.materialNo;
            parameters[5].Value = model.checkResult;
            parameters[6].Value = model.checkMark;
            parameters[7].Value = model.checkEmpId;
            parameters[8].Value = model.checkDt == string.Empty ? null : model.checkDt;
            parameters[9].Value = model.isrtEmpId;
            parameters[10].Value = model.isrtDt == string.Empty ? null : model.isrtDt;
            parameters[11].Value = model.updtEmpId;
            parameters[12].Value = model.updtDt == string.Empty ? null : model.updtDt;
            parameters[13].Value = model.commitEmpId;
            parameters[14].Value = model.commitDt == string.Empty ? null : model.commitDt;
            parameters[15].Value = model.instantState;

            try
            {
                SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
                ret = true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return ret;
        }
Esempio n. 4
0
    /// <summary>
    /// 数据保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (this.ValidataBillState())
        {
            string strInfo = "";
            bool isValidate = this.ValidatePageControlValue(out strInfo);

            if (isValidate)
            {
                BCheckBillBB checkBillBB = new BCheckBillBB();
                BCheckBillBC checkBillBC = new BCheckBillBC();

                try
                {
                    BCheckBillData model = new BCheckBillData();
                    List<BCheckDetailData> listDetail = this.SetDetailApplyBillModel();

                    if (this.State == "1")
                    {
                        this.SetModel(ref model);
                        model.checkBillNo = "";
                        model.isrtDt = DateTime.Now.ToString();
                        model.isrtEmpId = this.currentUser.empId;
                    }
                    else if (this.State == "2")
                    {
                        model = checkBillBB.GetModel(this.IdValue);
                        this.SetModel(ref model);
                        model.updtDt = DateTime.Now.ToString();
                        model.updtEmpId = this.currentUser.empId;
                    }

                    //保存检测单数据
                    checkBillBC.SavelData(model, listDetail, isReNew);

                    Response.Write("<script laguage=\"javascript\">alert('保存成功,请及时提交检测单!');</script>");// "alert", "alert('订单保存成功,请及时提交订单!!');", true);

                    Response.Redirect("BCheckBillList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false);
                    Response.Flush();
                    //this.IdValue = model.id;
                    //this.State = "2";
                    //this.ShowInfo(this.IdValue);
                    //this.DtResult = null;
                    //this.BindDetailTable("old");

                    return;
                }
                catch (Exception ex)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
                    return;
                }
                finally
                {
                    checkBillBB.Dispose();
                    checkBillBC.Dispose();
                    //Response.Redirect("BCheckBillList.aspx?&itemno=" + this.itemNo + "&pTypeNo=main", false);
                }
            }
            else
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('" + strInfo + "');", true);
            }
        }
    }
Esempio n. 5
0
 /// <summary>
 /// 实体类赋值
 /// </summary>
 /// <param name="model">实体类实例</param>
 private void SetModel(ref BCheckBillData model)
 {
     model.checkBillNo = this.lbCheckBillNo.Text;
     model.arriveBillNo = this.tbArriveBillNo.Text;
     model.financeBillNo = this.tbFinanceBillNo.Text;
     model.materialNo = this.hidMaterialNo.Value;
     model.checkMark = this.tbCheckMark.Text;
     model.instantState = "01";
 }
Esempio n. 6
0
        /// <summary>
        /// 更新一条"检验单"信息
        /// </summary>
        /// <param name="model">model</param>
        public bool ModifyRecord(BCheckBillData model)
        {
            bool ret = false;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransModify");
                    this.checkBillBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                this.checkBillBB.ModifyRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = model.id.ToString();
                operatDiaryData.operateContent = "检验单修改一条id为“" + model.id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
                ret = true;
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransModify");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "检验单修改记录“" + model.id.ToString() + "”时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return ret;
        }
Esempio n. 7
0
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// 保存检测单数据
        /// </summary>
        /// <param name="checkBillModel">检测单实例</param>
        /// <param name="detailModelList">检测单明细实例列表</param>
        /// <param name="isReNew">是否进行过初始化,如果进行过,则保存时,先删除旧数据。0否1是</param>
        /// <returns></returns>
        public string SavelData(BCheckBillData checkBillModel, List<BCheckDetailData> detailModelList,string isReNew)
        {
            SqlTransaction trans = null;
            BCheckDetailBB checkDetailBB = new BCheckDetailBB(this.connection);
            SCommBB commBB = new SCommBB(this.connection);

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TranSave");
                    checkBillBB.Transaction = trans;
                    checkDetailBB.Transaction = trans;
                    commBB.Transaction = trans;
                }
                else
                {
                    checkBillBB.Transaction = this.transaction;
                    checkDetailBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                }

                string strBillNo = "";

                if (isReNew == "1")//进行过初始化,则先删掉旧数据
                {
                    string strSQL = " delete from BCheckDetail where checkBillId='" + checkBillModel.id + "'";
                    commBB.Query(strSQL);
                }

                strBillNo = checkBillModel.checkBillNo;
                if (strBillNo == "")//新增
                {
                    checkBillModel.checkBillNo = checkBillBB.GetCurrentInBillNoByPreBillNo();
                    strBillNo = checkBillModel.checkBillNo;

                    //保存检测单主数据
                    int mainId = checkBillBB.AddRecord(checkBillModel);
                    checkBillModel.id = mainId;

                    //保存检测单明细数据
                    foreach (BCheckDetailData model in detailModelList)
                    {
                        if (model.openBoxNum != 0 && model.checkNum != 0)
                        {
                            model.checkBillId = mainId;
                            checkDetailBB.AddRecord(model);
                        }
                    }
                }
                else//修改
                {
                    //修改检测单主数据
                    checkBillBB.ModifyRecord(checkBillModel);

                    //明细
                    foreach (BCheckDetailData model in detailModelList)
                    {
                        if (model.id > 0 && model.checkBillId > 0)//修改 且未删除的明细
                        {
                            checkDetailBB.ModifyRecord(model);
                        }
                        else if (model.id > 0 && model.checkBillId == -1)//修改时,被删了。需从数据库删除
                        {
                            checkDetailBB.DeleteRecord(model.id);
                        }
                        else if (model.id == 0)//本次新增的检测明细项目
                        {
                            if (model.openBoxNum != 0 && model.checkNum != 0)
                            {
                                model.checkBillId = checkBillModel.id;
                                checkDetailBB.AddRecord(model);
                            }
                        }
                    }
                }

                if (transaction == null) trans.Commit();
                return strBillNo;
            }
            catch (Exception ex)
            {
                if (transaction == null) trans.Rollback("TranSave");
                throw new Exception(ex.Message);
            }
            finally
            {
                checkDetailBB.Dispose();
                commBB.Dispose();
            }
        }
Esempio n. 8
0
        /// <summary>
        /// 提交检测单
        /// </summary>
        /// <param name="checkBillModel">检测单实例</param>
        /// <returns></returns>
        public void CommitData(BCheckBillData checkBillModel)
        {
            SqlTransaction trans = null;
            LCheckDetailBB lCheckDetailBB = new LCheckDetailBB();
            BCheckDetailBB checkDetailBB = new BCheckDetailBB();
            SCommBB commBB = new SCommBB(this.connection);

            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TranCommit");
                    checkBillBB.Transaction = trans;
                    commBB.Transaction = trans;
                }
                else
                {
                    checkBillBB.Transaction = this.transaction;
                    commBB.Transaction = this.transaction;
                }

                DataSet dsCheckDetail = new DataSet();
                DataSet dsMaterialCheckDetail = new DataSet();
                DataSet dsArriveDetail = new DataSet();
                string strSql = "";
                DataRow[] myDataRowArray = null;

                //获取物料对应的检测项
                dsMaterialCheckDetail = lCheckDetailBB.GetList("materialNo='" + checkBillModel.materialNo + "'");

                //获取检测单对应到货单信息
                strSql = "select id,num from BArriveDetail where arriveBillNo='" + checkBillModel.arriveBillNo
                    + "' and financeBillNo='" + checkBillModel.financeBillNo + "' and materialNo='" + checkBillModel.materialNo + "'";
                dsArriveDetail = commBB.Query(strSql);

                //提交检测单
                this.checkBillBB.ModifyRecord(checkBillModel);

                //获取检测单下的所有检测明细
                dsCheckDetail = checkDetailBB.GetVList("checkBillId=" + checkBillModel.id);
                foreach (DataRow row in dsCheckDetail.Tables[0].Rows)
                {
                    if (Convert.ToBoolean(row["isAddupCheck"]))//检测明细是累计检测项
                    {
                        strSql = "update dbo.LCheckDetail set arrivedAmount=0 where id=" + row["checkDetailId"].ToString();
                        commBB.Query(strSql);
                        continue;
                    }

                    //当前物料存在累计检测项,当前没有检测,累计到货数量
                    myDataRowArray = dsMaterialCheckDetail.Tables[0].Select("id=" + row["checkDetailId"].ToString()
                        + " and isAddupCheck=1");
                    if (myDataRowArray.Length > 0)
                    {
                        strSql = "update dbo.LCheckDetail set arrivedAmount=isnull(arrivedAmount,0)+" + dsArriveDetail.Tables[0].Rows[0]["num"].ToString()
                            + " where id=" + row["checkDetailId"].ToString();
                        commBB.Query(strSql);
                    }
                }

                if (transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (transaction == null) trans.Rollback("TranCommit");
                throw new Exception(ex.Message);
            }
            finally
            {
                lCheckDetailBB.Dispose();
                checkDetailBB.Dispose();
                commBB.Dispose();
            }
        }
Esempio n. 9
0
        /// <summary>
        /// 增加一条"检验单"信息
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(BCheckBillData model)
        {
            int id = 0;
            SqlTransaction trans = null;
            try
            {
                if (this.transaction == null)
                {
                    trans = this.connection.BeginTransaction("TransAdd");
                    this.checkBillBB.Transaction = trans;
                    this.errorDiaryBB.Transaction = trans;
                    this.operatDiaryBB.Transaction = trans;
                }

                id = this.checkBillBB.AddRecord(model);

                SOperatDiaryData operatDiaryData = new SOperatDiaryData();
                operatDiaryData.empId = this.empId;
                operatDiaryData.functionId = "";
                operatDiaryData.recordId = id.ToString();
                operatDiaryData.operateContent = "检验单增加一条id为“" + id.ToString() + "”的记录";
                this.operatDiaryBB.AddRecord(operatDiaryData);

                if (this.transaction == null) trans.Commit();
            }
            catch (Exception ex)
            {
                if (this.transaction == null) trans.Rollback("TransAdd");
                SErrorDiaryData errorDiaryData = new SErrorDiaryData();
                errorDiaryData.empId = this.empId;
                errorDiaryData.functionId = "";
                errorDiaryData.errorText = "检验单增加记录时报错:" + ex.Message;
                this.errorDiaryBB.AddRecord(errorDiaryData);
                throw ex;
            }
            finally
            {
            }
            return id;
        }
Esempio n. 10
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="model">model</param>
 public bool ModifyRecord(BCheckBillData model)
 {
     return this.checkBillDB.ModifyRecord(model);
 }
Esempio n. 11
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(BCheckBillData model)
 {
     return this.checkBillDB.AddRecord(model);
 }
Esempio n. 12
0
    public bool FinishCheckBill(int checkBillId)
    {
        BCheckBillBB checkBillBB = new BCheckBillBB();

        try
        {
            BCheckBillData checkBillModel = new BCheckBillData();

            checkBillModel = checkBillBB.GetModel(checkBillId);
            checkBillModel.instantState = "04";

            return checkBillBB.ModifyRecord(checkBillModel);

        }
        finally
        {
            checkBillBB.Dispose();
        }
    }