Example #1
0
        public int AddModel(MaterialWantPlanModel model)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("insert into Sm_Wantplan(");
            builder.Append("swid,swcode,flowstate,person,intime,acceptstate,annx,explain,procode,EquipmentId)");
            builder.Append(" values (");
            builder.Append("@swid,@swcode,@flowstate,@person,@intime,@acceptstate,@annx,@explain,@procode,@EquipmentId)");
            SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@swid", SqlDbType.NVarChar, 50), new SqlParameter("@swcode", SqlDbType.NVarChar, 0x40), new SqlParameter("@flowstate", SqlDbType.Int, 4), new SqlParameter("@person", SqlDbType.NVarChar, 0x40), new SqlParameter("@intime", SqlDbType.SmallDateTime), new SqlParameter("@acceptstate", SqlDbType.Int, 4), new SqlParameter("@annx", SqlDbType.NVarChar, 0x80), new SqlParameter("@explain", SqlDbType.NVarChar, 0x800), new SqlParameter("@procode", SqlDbType.NVarChar, 100), new SqlParameter("@ContainPending", SqlDbType.Bit), new SqlParameter("@EquipmentId", SqlDbType.NVarChar, 500) };
            commandParameters[0].Value = model.swid;
            commandParameters[1].Value = model.swcode;
            commandParameters[2].Value = model.flowstate;
            commandParameters[3].Value = model.person;
            commandParameters[4].Value = model.intime;
            commandParameters[5].Value = model.acceptstate;
            commandParameters[6].Value = model.annx;
            commandParameters[7].Value = model.explain;
            commandParameters[8].Value = model.procode;
            commandParameters[9].Value = model.ContainPending;
            if (!string.IsNullOrEmpty(model.EquipmentId))
            {
                commandParameters[10].Value = model.EquipmentId;
            }
            else
            {
                commandParameters[10].Value = DBNull.Value;
            }
            return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters));
        }
Example #2
0
        public MaterialWantPlanModel ReaderBind(IDataReader dataReader)
        {
            MaterialWantPlanModel model = new MaterialWantPlanModel {
                swid   = dataReader["swid"].ToString(),
                swcode = dataReader["swcode"].ToString()
            };
            object obj2 = dataReader["flowstate"];

            if ((obj2 != null) && (obj2 != DBNull.Value))
            {
                model.flowstate = Convert.ToInt32(obj2);
            }
            model.person = dataReader["person"].ToString();
            obj2         = dataReader["intime"];
            if ((obj2 != null) && (obj2 != DBNull.Value))
            {
                model.intime = Convert.ToString(obj2);
            }
            obj2 = dataReader["acceptstate"];
            if ((obj2 != null) && (obj2 != DBNull.Value))
            {
                model.acceptstate = Convert.ToInt32(obj2);
            }
            model.annx           = dataReader["annx"].ToString();
            model.explain        = dataReader["explain"].ToString();
            model.procode        = dataReader["procode"].ToString();
            model.ContainPending = DBHelper.GetBool(dataReader["ContainPending"]);
            model.EquipmentId    = dataReader["EquipmentId"].ToString();
            return(model);
        }
Example #3
0
        private void PrepareAddCommand(MaterialWantPlanModel model, out string cmdText, out SqlParameter[] parameters)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append(" insert into Sm_Wantplan(swid,swcode,flowstate,person,intime,acceptstate,annx,explain,procode,ContainPending,EquipmentId) values(@swid,@swcode,@flowstate,@person,@intime,@acceptstate,@annx,@explain,@procode,@ContainPending,@EquipmentId)");
            SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@swid", SqlDbType.NVarChar, 50), new SqlParameter("@swcode", SqlDbType.NVarChar, 0x40), new SqlParameter("@flowstate", SqlDbType.Int, 0x10), new SqlParameter("@person", SqlDbType.NVarChar, 0x40), new SqlParameter("@intime", SqlDbType.SmallDateTime, 8), new SqlParameter("@acceptstate", SqlDbType.Int, 0x10), new SqlParameter("@annx", SqlDbType.NVarChar, 0x80), new SqlParameter("@explain", SqlDbType.NVarChar, 0x800), new SqlParameter("@procode", SqlDbType.NVarChar, 100), new SqlParameter("@ContainPending", SqlDbType.Bit), new SqlParameter("@EquipmentId", SqlDbType.NVarChar, 500) };
            parameterArray[0].Value = model.swid;
            parameterArray[1].Value = model.swcode;
            parameterArray[2].Value = model.flowstate;
            parameterArray[3].Value = model.person;
            parameterArray[4].Value = model.intime;
            parameterArray[5].Value = model.acceptstate;
            parameterArray[6].Value = model.annx;
            parameterArray[7].Value = model.explain;
            parameterArray[8].Value = model.procode;
            parameterArray[9].Value = model.ContainPending;
            if (!string.IsNullOrEmpty(model.EquipmentId))
            {
                parameterArray[10].Value = model.EquipmentId;
            }
            else
            {
                parameterArray[10].Value = DBNull.Value;
            }
            cmdText    = builder.ToString();
            parameters = parameterArray;
        }
Example #4
0
    protected void setControlsValue()
    {
        MaterialWantPlanModel model = this.materialWant.GetModel(this.wantplanCode);

        this.hfldWantPlanGuid.Value    = model.swid;
        this.txtCode.Text              = model.swcode;
        this.hdnProjectCode.Value      = model.procode;
        this.txtPerson.Text            = model.person;
        this.txtInputDate.Text         = model.intime.Replace("0:00:00", "").Trim();
        this.txtRemark.Text            = model.explain;
        this.chkContainPending.Checked = model.ContainPending;
        string equipmentId = model.EquipmentId;

        if (!string.IsNullOrEmpty(equipmentId))
        {
            this.hfldEquId.Value = equipmentId;
            EquEquipmentService equEquipmentService = new EquEquipmentService();
            EquEquipment        byId = equEquipmentService.GetById(equipmentId);
            if (byId != null)
            {
                this.txtEquCode.Value = byId.EquCode;
            }
        }
        DataTable dataTable = this.materialStock.showMaterialListForUpdate(this.wantplanCode);
        //this.ViewState["ResourcesTable"] = dataTable;
        DataTable dtCopy = dataTable.Copy();

        try
        {
            DataColumn dataColumn1 = new DataColumn();
            dataColumn1.ColumnName = "ResourceQuantity";
            dataColumn1.DataType   = System.Type.GetType("System.String");
            dtCopy.Columns.Add(dataColumn1);

            DataColumn dataColumn2 = new DataColumn();
            dataColumn2.ColumnName = "numberIng";
            dataColumn2.DataType   = System.Type.GetType("System.String");
            dtCopy.Columns.Add(dataColumn2);
        }
        catch
        {
        }
        //DataTable dt = dtNum();
        foreach (DataRow drc in dtCopy.Rows)
        {
            foreach (DataRow dr in dtNum().Rows)
            {
                if (drc["ResourceCode"].ToString().Trim() == dr["scode"].ToString().Trim())
                {
                    drc["ResourceQuantity"] = dr["ResourceQuantity"];
                    drc["numberIng"]        = dr["numberIng"];
                }
            }
        }
        this.ViewState["ResourcesTable"]  = dtCopy;
        this.gvSmWantPlanStock.DataSource = dtCopy;
        //this.gvSmWantPlanStock.DataSource = dataTable;
        this.gvSmWantPlanStock.DataBind();
    }
Example #5
0
        public int Update(SqlTransaction trans, MaterialWantPlanModel model)
        {
            SqlParameter[] parameterArray;
            string         cmdText = string.Empty;

            this.PrepareUpdateCommand(model, out cmdText, out parameterArray);
            return(SqlHelper.ExecuteNonQuery(trans, CommandType.Text, cmdText, parameterArray));
        }
Example #6
0
        public int Add(MaterialWantPlanModel model)
        {
            SqlParameter[] parameterArray;
            string         cmdText = string.Empty;

            this.PrepareAddCommand(model, out cmdText, out parameterArray);
            return(SqlHelper.ExecuteNonQuery(CommandType.Text, cmdText, parameterArray));
        }
Example #7
0
    private void DataBindDiff()
    {
        MaterialWantPlanModel model = this.materialWant.GetModel(this.wantplanCode);
        DataTable             diff  = this.materialWant.GetDiff(model, this.hfldIsWBSRelevance.Value);

        this.gvwDiff.DataSource = diff;
        this.gvwDiff.DataBind();
    }
Example #8
0
 protected void setModelValue(MaterialWantPlanModel modelPlan)
 {
     modelPlan.swid           = this.hfldWantPlanGuid.Value;
     modelPlan.swcode         = this.txtCode.Text;
     modelPlan.procode        = this.hdnProjectCode.Value;
     modelPlan.person         = this.txtPerson.Text;
     modelPlan.intime         = System.DateTime.Now.ToString();
     modelPlan.explain        = this.txtRemark.Text;
     modelPlan.ContainPending = this.chkContainPending.Checked;
     modelPlan.EquipmentId    = this.hfldEquId.Value;
     modelPlan.annx           = "";
 }
Example #9
0
    protected void setControlsValue()
    {
        MaterialWantPlanModel model = this.materialWant.GetModel(this.wantplanCode);

        this.hfldWantPlanGuid.Value = model.swid;
        this.lblCode.Text           = model.swcode;
        if (!string.IsNullOrEmpty(model.procode))
        {
            this.prjId = model.procode;
            PrjInfoModel modelByPrjGuid = this.ptPrjInfo.GetModelByPrjGuid(model.procode);
            if (modelByPrjGuid != null)
            {
                this.lblPrjName.Text = modelByPrjGuid.PrjName;
            }
            else
            {
                DataTable tableByPrjGuid = this.ptPrjInfo.GetTableByPrjGuid(model.procode);
                if (tableByPrjGuid.Rows.Count > 0)
                {
                    this.lblPrjName.Text = tableByPrjGuid.Rows[0]["prjName"].ToString().Trim();
                }
            }
        }
        this.lblPerson.Text      = model.person;
        this.lblBllProducer.Text = model.person;
        this.lblPrintDate.Text   = System.DateTime.Now.ToShortDateString();
        this.dtxtApplyDate.Text  = model.intime.Replace("0:00:00", "").Trim();
        this.txtRemark.Value     = model.explain;
        this.lblRemark.Text      = model.explain;
        string equipmentId = model.EquipmentId;

        if (!string.IsNullOrEmpty(equipmentId))
        {
            EquEquipmentService equEquipmentService = new EquEquipmentService();
            EquEquipment        byId = equEquipmentService.GetById(equipmentId);
            if (byId != null)
            {
                this.lblEquCode.Text = byId.EquCode;
            }
        }
        DataTable dataTable = this.materialStock.showMaterialListForUpdate(this.wantplanCode);

        if (dataTable != null && dataTable.Rows.Count > 0)
        {
            this.gvSmWantPlanStock.DataSource = dataTable;
            this.gvSmWantPlanStock.DataBind();
        }
        this.DataBindDiff();
        this.DataBindTaskDiff();
    }
Example #10
0
        public MaterialWantPlanModel GetModel(string swcode)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("select swid,swcode,flowstate,person,intime,acceptstate,annx,explain,procode,ContainPending,EquipmentId from Sm_Wantplan ");
            builder.Append(" where swcode=@swcode ");
            MaterialWantPlanModel model = null;

            using (IDataReader reader = SqlHelper.ExecuteReader(CommandType.Text, builder.ToString(), new SqlParameter[] { new SqlParameter("@swcode", swcode) }))
            {
                if (reader.Read())
                {
                    model = this.ReaderBind(reader);
                }
            }
            return(model);
        }
Example #11
0
        public void PrepareUpdateCommand(MaterialWantPlanModel model, out string cmdText, out SqlParameter[] parameters)
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("update Sm_Wantplan set ");
            builder.Append("swid=@swid,");
            builder.Append("flowstate=@flowstate,");
            builder.Append("person=@person,");
            builder.Append("intime=@intime,");
            builder.Append("acceptstate=@acceptstate,");
            builder.Append("annx=@annx,");
            builder.Append("explain=@explain,");
            builder.Append("procode=@procode,");
            builder.Append("ContainPending=@ContainPending,");
            builder.Append("EquipmentId=@EquipmentId");
            builder.Append(" where swcode=@swcode ");
            cmdText             = builder.ToString();
            parameters          = new SqlParameter[] { new SqlParameter("@swid", SqlDbType.NVarChar, 50), new SqlParameter("@swcode", SqlDbType.NVarChar, 0x40), new SqlParameter("@flowstate", SqlDbType.Int, 4), new SqlParameter("@person", SqlDbType.NVarChar, 0x40), new SqlParameter("@intime", SqlDbType.SmallDateTime), new SqlParameter("@acceptstate", SqlDbType.Int, 4), new SqlParameter("@annx", SqlDbType.NVarChar, 0x80), new SqlParameter("@explain", SqlDbType.NVarChar, 0x800), new SqlParameter("@procode", SqlDbType.NVarChar, 100), new SqlParameter("@ContainPending", SqlDbType.Bit), new SqlParameter("@EquipmentId", SqlDbType.NVarChar, 500) };
            parameters[0].Value = model.swid;
            parameters[1].Value = model.swcode;
            parameters[2].Value = model.flowstate;
            parameters[3].Value = model.person;
            parameters[4].Value = model.intime;
            parameters[5].Value = model.acceptstate;
            parameters[6].Value = model.annx;
            parameters[7].Value = model.explain;
            parameters[8].Value = model.procode;
            parameters[9].Value = model.ContainPending;
            if (!string.IsNullOrEmpty(model.EquipmentId))
            {
                parameters[10].Value = model.EquipmentId;
            }
            else
            {
                parameters[10].Value = DBNull.Value;
            }
        }
Example #12
0
        public DataTable GetDiff(MaterialWantPlanModel model, string isWBSRelevance)
        {
            string procode = model.procode;

            return(this.wantPlan.GetDiff(model.swcode, procode, isWBSRelevance));
        }
Example #13
0
 public int AddModel(MaterialWantPlanModel model)
 {
     return(this.wantPlan.AddModel(model));
 }
Example #14
0
 public int Add(SqlTransaction trans, MaterialWantPlanModel model)
 {
     return(this.wantPlan.Add(trans, model));
 }
Example #15
0
 public int Update(MaterialWantPlanModel model)
 {
     return(this.wantPlan.Update(model));
 }
Example #16
0
 private void save(string type)
 {
     if (this.opType == "add")
     {
         using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString))
         {
             sqlConnection.Open();
             SqlTransaction sqlTransaction = sqlConnection.BeginTransaction();
             try
             {
                 MaterialWantPlanModel materialWantPlanModel = new MaterialWantPlanModel();
                 this.setModelValue(materialWantPlanModel);
                 this.materialWant.Add(sqlTransaction, materialWantPlanModel);
                 string empty = string.Empty;
                 if (this.addMaterialList(sqlTransaction, ref empty))
                 {
                     if (!string.IsNullOrEmpty(empty))
                     {
                         if (type == "pc")
                         {
                             base.RegisterScript(string.Concat(new string[]
                             {
                                 "top.ui.show('",
                                 empty,
                                 "<br />添加成功');winclose('SmWantPlan', 'SmWantPlanList.aspx?prjId=",
                                 this.projectCode,
                                 "', true)"
                             }));
                         }
                         else
                         {
                             StringBuilder stringBuilder = new StringBuilder();
                             stringBuilder.Append("alert('添加成功');");
                             stringBuilder.Append("parent.location.reload();");
                             base.RegisterScript(stringBuilder.ToString());
                         }
                     }
                     else
                     {
                         if (type == "pc")
                         {
                             base.RegisterScript("top.ui.show('添加成功');winclose('SmWantPlan', 'SmWantPlanList.aspx?prjId=" + this.projectCode + "', true)");
                         }
                         else
                         {
                             StringBuilder stringBuilder = new StringBuilder();
                             stringBuilder.Append("alert('添加成功');");
                             stringBuilder.Append("parent.location.reload();");
                             base.RegisterScript(stringBuilder.ToString());
                         }
                     }
                     sqlTransaction.Commit();
                 }
                 else
                 {
                     if (type == "pc")
                     {
                         base.RegisterScript("top.ui.show('" + empty + "<br />添加失败');");
                     }
                     else
                     {
                         base.RegisterScript("alert('系统提示:\\n\\n添加失败!');");
                     }
                     sqlTransaction.Rollback();
                 }
             }
             catch (System.Exception ex)
             {
                 sqlTransaction.Rollback();
                 if (type == "pc")
                 {
                     base.RegisterScript("top.ui.show('添加失败');winclose('SmWantPlan', 'SmWantPlanList.aspx?prjId=" + this.projectCode + "', true)");
                 }
                 else
                 {
                     base.RegisterScript("alert('系统提示:\\n\\n添加失败!');");
                 }
             }
             return;
         }
     }
     using (SqlConnection sqlConnection2 = new SqlConnection(SqlHelper.ConnectionString))
     {
         sqlConnection2.Open();
         SqlTransaction sqlTransaction2 = sqlConnection2.BeginTransaction();
         try
         {
             MaterialWantPlanModel model = this.materialWant.GetModel(this.wantplanCode);
             model.swcode         = this.txtCode.Text;
             model.procode        = this.hdnProjectCode.Value;
             model.person         = this.txtPerson.Text;
             model.intime         = this.txtInputDate.Text;
             model.explain        = this.txtRemark.Text;
             model.ContainPending = this.chkContainPending.Checked;
             model.EquipmentId    = this.hfldEquId.Value;
             this.materialWant.Update(sqlTransaction2, model);
             this.materialStock.DeleteByWantplanCode(sqlTransaction2, this.wantplanCode);
             string empty2 = string.Empty;
             if (this.addMaterialList(sqlTransaction2, ref empty2))
             {
                 if (!string.IsNullOrEmpty(empty2))
                 {
                     if (type == "pc")
                     {
                         base.RegisterScript(string.Concat(new string[]
                         {
                             "top.ui.show('",
                             empty2,
                             "<br />修改成功');winclose('SmWantPlan', 'SmWantPlanList.aspx?prjId=",
                             this.projectCode,
                             "', true)"
                         }));
                     }
                     else
                     {
                         StringBuilder stringBuilder = new StringBuilder();
                         stringBuilder.Append("alert('添加成功');");
                         stringBuilder.Append("parent.location.reload();");
                         base.RegisterScript(stringBuilder.ToString());
                     }
                 }
                 else
                 {
                     if (type == "pc")
                     {
                         base.RegisterScript("top.ui.show('修改成功');winclose('SmWantPlan', 'SmWantPlanList.aspx?prjId=" + this.projectCode + "', true)");
                     }
                     else
                     {
                         StringBuilder stringBuilder = new StringBuilder();
                         stringBuilder.Append("alert('添加成功');");
                         stringBuilder.Append("parent.location.reload();");
                         base.RegisterScript(stringBuilder.ToString());
                     }
                 }
                 sqlTransaction2.Commit();
             }
             else
             {
                 if (type == "pc")
                 {
                     base.RegisterScript("top.ui.show('" + empty2 + "<br />修改失败');");
                 }
                 else
                 {
                     base.RegisterScript("alert('系统提示:\\n\\n添加失败!');");
                 }
                 sqlTransaction2.Rollback();
             }
         }
         catch (System.Exception)
         {
             sqlTransaction2.Rollback();
             if (type == "pc")
             {
                 base.RegisterScript("top.ui.show('修改失败');winclose('SmWantPlan', 'SmWantPlanList.aspx?prjId=" + this.projectCode + "', true)");
             }
             else
             {
                 base.RegisterScript("alert('系统提示:\\n\\n添加失败!');");
             }
         }
     }
 }