コード例 #1
0
        protected void btnSaveRcd_Click(object sender, EventArgs e)
        {
            this.txtSN.Focus();
            try
            {
                int j = ((DataSet)ViewState["tmpds"]).Tables[0].Rows.Count;
                if (j == 0)
                {
                    Methods.AjaxMessageBox(this, "没有记录要添加到数据库"); return;
                }
                for (int i = 0; i < j; i++)
                {
                    DataRow r = ((DataSet)ViewState["tmpds"]).Tables[0].Rows[i];
                    if (r["Batch"].ToString() == "" || r["Vendor"].ToString() == "")
                    {
                        Methods.AjaxMessageBox(this, "批次号及供应商信息不能为空!"); return;
                    }
                }

                sqlaccess.Open();
                sqlaccess.BeginTransaction();

                for (int i = 0; i < j; i++)
                {
                    SqlCommand cmd = new SqlCommand();
                    DataRow    r   = ((DataSet)ViewState["tmpds"]).Tables[0].Rows[i];
                    cmd.Parameters.AddWithValue("@p1", r["ID"]);
                    cmd.Parameters.AddWithValue("@p2", r["ModelID"]);
                    cmd.Parameters.AddWithValue("@p3", r["Batch"]);
                    cmd.Parameters.AddWithValue("@p4", r["Vendor"]);
                    cmd.Parameters.AddWithValue("@p5", r["EmployeeID"]);
                    cmd.Parameters.AddWithValue("@p6", r["FoundTime"]);
                    cmd.Parameters.AddWithValue("@p7", r["Remark"]);

                    cmd.CommandText = "INSERT INTO TA_Materiel(ID, ModelID, Batch, Vendor, EmployeeID, FoundTime, Remark) VALUES (@p1,@p2,@p3,@p4,@p5,@p6,@p7)";

                    sqlaccess.ExecuteQuerry(cmd);
                }
                Methods.AjaxMessageBox(this, "数据成功保存到数据库!");
                sqlaccess.Commit();
                ((DataSet)ViewState["tmpds"]).Tables[0].Rows.Clear();
                this.GridView1.DataSource = (DataSet)ViewState["tmpds"];
                this.GridView1.DataBind();
            }
            catch (Exception ex)
            {
                sqlaccess.Rollback();
                if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
                {
                    char[] cs = { '\r', '\n' }; Methods.AjaxMessageBox(this, ex.Message.Split(cs)[0].Replace('\'', '"'));
                }
                LogManager.Write(this, ex.Message);
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #2
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                foreach (GridViewRow row in this.GridView1.Rows)
                {
                    CheckBox ck = (CheckBox)row.FindControl("ckid");
                    if (ck.Checked)
                    {
                        string tmpstr=ViewState["groupID"].ToString();
                        SqlCommand cmd = new SqlCommand();
                        cmd.Parameters.AddWithValue("@p1", this.GridView1.DataKeys[row.RowIndex].Value.ToString());
                        cmd.Parameters.AddWithValue("@p2", tmpstr);
                        cmd.CommandText = "insert into TRE_Group_Employee (groupid,employeeid) values(@p2,@p1)";
                        sqlaccess.ExecuteQuerry(cmd);                        
                        
                        //添加的班组成员自动设为“作业员”角色
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@p1", this.GridView1.DataKeys[row.RowIndex].Value.ToString());
                        cmd.Parameters.AddWithValue("@p2", "作业员");
                        cmd.CommandText = "select * from TRE_Employee_Role where Role=@p2 and employeeid=@p1";
                        ds= sqlaccess.OpenQuerry(cmd);
                        if(ds!=null&&ds.Tables[0].Rows.Count>0)
                        {
                            continue;
                        }
                        
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@p1", this.GridView1.DataKeys[row.RowIndex].Value.ToString());
                        cmd.Parameters.AddWithValue("@p2", "作业员");
                        cmd.CommandText = "insert into TRE_Employee_Role (EmployeeID,Role) values(@p1,@p2)";
                        sqlaccess.ExecuteQuerry(cmd);
                    }

                }
                sqlaccess.Commit();
                this.GridBind();
                Methods.Write(this, "window.parent.document.getElementById('btnrefresh').click();window.parent.closeit();//关闭窗体 ");

            }
            catch (Exception ex)
            {
                sqlaccess.Rollback();
                if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
                {
                    char[] cs = { '\r', '\n' };Methods.AjaxMessageBox(this, ex.Message.Split(cs)[0].Replace('\'', '"'));
                }
                LogManager.Write(this, ex.Message);
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #3
0
        /// <summary>
        /// 删除时触发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (this.GridView1.EditIndex != -1)
            {
                this.lblMsg.Visible = true;
                return;
            }
            Label  lbl    = (Label)this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lblid"); //强行转换为lable控件
            string delstr = "delete from TA_Model  where id='" + lbl.Text + "'";                  //取编号值

            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                sqlaccess.ExecuteQuerry(delstr);
                string logStr = "删除品号[" + lbl.Text + "] ## " + delstr;
                Methods.WriteOprationLog(SessionUser.ID, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logStr);

                sqlaccess.Commit();
                LogManager.WriteOprationLog(SessionUser.DetailInfo, delstr);
                this.GridView1.EditIndex = -1;
                this.lblMsg.Visible      = false;
                //删除后重新绑定
                this.GridBind();
            }
            catch (Exception ex)
            {
                if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
                {
                    sqlaccess.Rollback();
                    this.lblMsg.Text    = "尚有其它表的记录与它相关联,不能删除!";
                    this.lblMsg.Visible = true;
                }
                else
                {
                    LogManager.Write(this, ex.ToString());
                }
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #4
0
ファイル: ManageGroup.aspx.cs プロジェクト: cancelpj/MCS_Core
 /// <summary>
 /// 批量删除
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btndelete_Click(object sender, EventArgs e)
 {
     try
     {
         sqlaccess.Open();
         sqlaccess.BeginTransaction();
         foreach (GridViewRow row in this.GridView2.Rows)
         {
             CheckBox ck = (CheckBox)row.FindControl("ckID");
             if (ck.Checked)
             {
                 SqlCommand cmd = new SqlCommand();
                 cmd.Parameters.AddWithValue("@p1", this.GridView2.DataKeys[row.RowIndex].Value.ToString());
                 cmd.Parameters.AddWithValue("@p2", this.GridView1.DataKeys[this.GridView1.SelectedIndex].Value.ToString());
                 cmd.CommandText = "delete TRE_Group_Employee where groupid=@p2 and employeeid=@p1";
                 sqlaccess.ExecuteQuerry(cmd);
                 cmd.Parameters.Clear();
                 cmd.Parameters.AddWithValue("@p1", this.GridView2.DataKeys[row.RowIndex].Value.ToString());
                 cmd.Parameters.AddWithValue("@p2", "作业员");
                 cmd.CommandText = "delete TRE_Employee_Role where Role=@p2 and employeeid=@p1";
                 sqlaccess.ExecuteQuerry(cmd);
             }
         }
         sqlaccess.Commit();
         this.grid2Bind(this.GridView1.DataKeys[this.GridView1.SelectedIndex].Value.ToString());
     }
     catch (Exception ex)
     {
         sqlaccess.Rollback();
         if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
         {
             Methods.AjaxMessageBox(this, "尚有其它数据与此数据关联,暂不能删除!"); return;
         }
         LogManager.Write(this, ex.Message);
     }
     finally
     {
         sqlaccess.Close();
     }
 }
コード例 #5
0
        protected void GridView2_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (this.GridView2.EditIndex != -1)
            {
                this.lblMsg.Visible = true;
                this.lblMsg.Text    = "表格正处在编辑状态,请先保存或取消!";
                return;
            }
            string id     = this.GridView2.DataKeys[e.RowIndex].Value.ToString();
            string delstr = "delete from TA_BugPoint  where ModelID='" + ((Label)this.GridView2.Rows[e.RowIndex].FindControl("lblModelID")).Text + "' and BugPointCode='" + id + "'";//取单位值

            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                sqlaccess.ExecuteQuerry(delstr);
                sqlaccess.Commit();
                //删除后重新绑定
                //this.grid2Bind(((Label)this.GridView2.Rows[e.RowIndex].FindControl("lblModelID")).Text);
                this.grid2Bind();
            }
            catch (Exception ex)
            {
                if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
                {
                    sqlaccess.Rollback();
                    this.lblMsg.Text    = "尚有其它表的记录与它相关联,不能删除!";
                    this.lblMsg.Visible = true;
                }
                else
                {
                    LogManager.Write(this, ex.ToString());
                }
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #6
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (this.GridView1.EditIndex != -1)
            {
                this.lblMsg.Visible = true;
                return;
            }
            string id     = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
            string delstr = "delete from TA_Group  where id='" + id + "'";//取单位值

            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                sqlaccess.ExecuteQuerry(delstr);
                string logStr = delstr;
                //Methods.WriteOprationLog(SessionUser.ID, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logStr);
                sqlaccess.Commit();
                //删除后重新绑定
                this.GridBind();
            }
            catch (Exception ex)
            {
                if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
                {
                    sqlaccess.Rollback();
                    this.lblMsg.Text    = "尚有其它表的记录与它相关联,不能删除!";
                    this.lblMsg.Visible = true;
                }
                else
                {
                    LogManager.Write(this, ex.ToString());
                }
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #7
0
        protected void btnSaveRcd_Click(object sender, EventArgs e)
        {
            try
            {
                int j = ((DataSet)ViewState["tmpds"]).Tables[0].Rows.Count;
                if (j == 0)
                {
                    Methods.AjaxMessageBox(this, "没有记录要添加到数据库");
                }
                sqlaccess.Open();
                sqlaccess.BeginTransaction();

                for (int i = 0; i < j; i++)
                {
                    SqlCommand cmd = new SqlCommand();
                    DataRow    r   = ((DataSet)ViewState["tmpds"]).Tables[0].Rows[i];
                    cmd.Parameters.AddWithValue("@p1", r["ID"]);
                    cmd.Parameters.AddWithValue("@p2", r["SN"]);

                    cmd.CommandText = "update TA_Product set SN=@p2 where ID=@p1";

                    sqlaccess.ExecuteQuerry(cmd);
                }
                Methods.AjaxMessageBox(this, "数据成功保存到数据库!");
                sqlaccess.Commit();
                ((DataSet)ViewState["tmpds"]).Tables[0].Rows.Clear();
                this.GridView1.DataSource = (DataSet)ViewState["tmpds"];
                this.GridView1.DataBind();

                this.btnAddRcd.Text = "验证产品序列号";
                this.lblCode.Text   = "扫描产品序列号";
                this.txtID.Visible  = true;
                this.txtID.Text     = "";
                this.txtSN.Visible  = false;

                this.txtID.Focus();
            }
            catch (Exception ex)
            {
                sqlaccess.Rollback();
                if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
                {
                    char[] cs = { '\r', '\n' }; Methods.AjaxMessageBox(this, ex.Message.Split(cs)[0].Replace('\'', '"'));
                }
                LogManager.Write(this, ex.Message);
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #8
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (this.GridView1.EditIndex != -1)
            {
                this.lblMsg.Visible = true;
                this.lblMsg.Text    = "表格正处在编辑状态,请先保存或取消!";
                return;
            }
            string Name   = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
            string delstr = "delete from TB_SoftwareVersion  where Name='" + Name + "'";//取单位值

            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                sqlaccess.ExecuteQuerry(delstr);
                sqlaccess.Commit();
                //删除后重新绑定
                this.GridBind();
            }
            catch (Exception ex)
            {
                if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
                {
                    sqlaccess.Rollback();
                    this.lblMsg.Text    = "尚有其它表的记录与它相关联,不能删除!";
                    this.lblMsg.Visible = true;
                }
                else
                {
                    LogManager.Write(this, ex.ToString());
                }
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #9
0
        protected void btnChaiChu_Click(object sender, EventArgs e)
        {
            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                Guid gid = Guid.NewGuid();
                if (this.TreeView1.Nodes == null || this.TreeView1.Nodes.Count == 0)
                {
                    Methods.AjaxMessageBox(this, "数据库中不存在您要拆除的产品!"); return;
                }
                string     ID  = this.TreeView1.Nodes[0].Value;// ((Label)this.GridView1.SelectedRow.FindControl("lblid")).Text.Trim();//生产序列号
                SqlCommand cmd = new SqlCommand();
                cmd.Parameters.AddWithValue("@p1", ID);
                cmd.Parameters.AddWithValue("@p2", gid.ToString());
                cmd.CommandText = " update ta_product set ManufactureState='报废' /*报废*/ ,sn=@p2 where ID=@p1 ";
                sqlaccess.ExecuteQuerry(cmd);

                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@p1", ID);

                cmd.CommandText = " delete from TA_Relationship where ID=@p1 ";
                sqlaccess.ExecuteQuerry(cmd);
                sqlaccess.Commit();

                string logstr = string.Format(" update ta_product where ManufactureState='报废' /*报废*/ ,sn={1} where ID='{0}' ", ID, gid.ToString());
                logstr = logstr + string.Format("delete from TA_Relationship where ID='{0}' ", ID);
                string strLog = "腔体拆空[" + ID.ToString() + "] ";
                Methods.WriteOprationLog(SessionUser.ID, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), strLog + logstr);
                Methods.AjaxMessageBox(this, "拆除成功!");
                this.TreeView1.Nodes.Clear();
            }
            catch (Exception ex)
            {
                LogManager.Write(this, ex.Message);
                sqlaccess.Rollback();
                if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
                {
                    char[] cs = { '\r', '\n' }; Methods.AjaxMessageBox(this, ex.Message.Split(cs)[0].Replace('\'', '"'));
                }
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #10
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //没有实现
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                SqlCommand cmd = new SqlCommand();

                cmd.Parameters.AddWithValue("@p1", this.lblProductID.Text);
                cmd.Parameters.AddWithValue("@p2", txtPlanIDNew.Text);
                cmd.Parameters.AddWithValue("@p3", ViewState["procedureid"].ToString());//取得流程号 由品号
                cmd.Parameters.AddWithValue("@p4", this.txtRPInfo.Text.Trim() + System.DateTime.Now.ToString("yyyy年MM月dd日 HH时mm分ss秒") + ",客退登记,原计划单号:" + this.lblOldPlanID.Text);
                cmd.CommandText = "update ta_product set planid=@p2,ProcedureID=@p3,remark=remark+@p4 where id=@p1";

                sqlaccess.ExecuteQuerry(cmd);

                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@p1", this.lblProductID.Text);
                //cmd.Parameters.AddWithValue("@p2",this.lblModelID.Text);
                cmd.CommandText = "delete TB_ProcedureState where ProductID=@p1";

                sqlaccess.ExecuteQuerry(cmd);

                sqlaccess.Commit();

                this.lblModelID.Text   = "----";
                this.lblOldPlanID.Text = "----";
                this.lblProductID.Text = "----";
                this.lblSN.Text        = "----";
                this.txtRPInfo.Text    = "";
                this.txtID.Text        = "";

                ctrlState(false);
            }
            catch (Exception ex)
            {
                sqlaccess.Rollback();
                LogManager.Write("", ex.Message);
                Methods.AjaxMessageBox(this, "向数据库中插入记录的时候出现异常!");
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #11
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
            case "Close":
                try
                {
                    int         index = Convert.ToInt32(e.CommandArgument);
                    GridViewRow row   = GridView1.Rows[index];
                    Label       lbl   = (Label)row.FindControl("lblid");//强行转换为lable控件

                    sqlaccess.Open();
                    sqlaccess.BeginTransaction();
                    SqlCommand cmd = new SqlCommand();

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@p1", lbl.Text);
                    cmd.Parameters.AddWithValue("@p2", 3);
                    cmd.Parameters.AddWithValue("@p3", System.DateTime.Now);
                    cmd.CommandText = "update ta_plan set State=@p2, CloseTime=@p3 where id=@p1";
                    sqlaccess.ExecuteQuerry(cmd);

                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@p1", lbl.Text);
                    cmd.CommandText = "delete TC_PlanProcedure where planid=@p1";
                    sqlaccess.ExecuteQuerry(cmd);

                    sqlaccess.Commit();
                    string strLog = "关闭计划单[" + lbl.Text + "] ## ";
                    Methods.WriteOprationLog(SessionUser.ID, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), strLog + "update ta_plan set State=3 where id=" + lbl.Text + ";delete TC_PlanProcedure where planid='" + lbl.Text + "'");
                    //Methods.Write(this, "window.parent.closeit();window.parent.query()"); return;
                    this.GridBind();
                }
                catch (Exception ex)
                {
                    LogManager.Write(this, ex.Message);
                }
                finally
                {
                    sqlaccess.Close();
                }
                break;
            }
        }
コード例 #12
0
        protected void btnSaveRcd_Click(object sender, EventArgs e)
        {
            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();

                if (this.TreeRShip.Nodes.Count > 0)
                {
                    string delstr = "delete ta_relationship where id='" + this.TreeRShip.Nodes[0].Value + "'";
                    sqlaccess.ExecuteQuerry(delstr);
                    if (this.TreeRShip.Nodes[0].ChildNodes.Count > 0)
                    {
                        for (int i = 0; i < this.TreeRShip.Nodes[0].ChildNodes.Count; i++)
                        {
                            SqlCommand cmd = new SqlCommand();
                            cmd.Parameters.AddWithValue("@p1", this.TreeRShip.Nodes[0].Value);
                            cmd.Parameters.AddWithValue("@p2", this.TreeRShip.Nodes[0].ChildNodes[i].Value);
                            cmd.CommandText = "insert into ta_relationship (id,itemid) values (@p1,@p2)";
                            sqlaccess.ExecuteQuerry(cmd);
                        }
                    }
                }
                sqlaccess.Commit();
                Methods.AjaxMessageBox(this, "保存成功!");
            }
            catch (Exception ex)
            {
                sqlaccess.Rollback();
                LogManager.Write(this, ex.Message);
                if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
                {
                    char[] cs = { '\r', '\n' }; Methods.AjaxMessageBox(this, ex.Message.Split(cs)[0].Replace('\'', '"'));
                }
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #13
0
        protected void btnSaveRcd_Click(object sender, EventArgs e)
        {
            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                for (int i = 0; i < ((DataTable)ViewState["dt"]).Rows.Count; i++)
                {
                    if (((DataTable)ViewState["dt"]).Rows[i]["upid"].ToString() == "" ||
                        ((DataTable)ViewState["dt"]).Rows[i]["dnid"].ToString() == ""
                        )
                    {
                        Methods.AjaxMessageBox(this, "换上或换下的序列号不能为空!"); return;
                    }
                    SqlCommand cmd = new SqlCommand();
                    cmd.Parameters.AddWithValue("@p1", ViewState["productID"].ToString());
                    cmd.Parameters.AddWithValue("@p2", ((DataTable)ViewState["dt"]).Rows[i]["upid"].ToString());
                    cmd.Parameters.AddWithValue("@p3", ((DataTable)ViewState["dt"]).Rows[i]["dnid"].ToString());

                    cmd.CommandText = "update ta_relationship set itemid=@p2 where id=@p1 and itemid=@p3 ";

                    sqlaccess.ExecuteQuerry(cmd);
                }
                sqlaccess.Commit();
                this.txtDownID.Text = this.txtUPID.Text = this.txtProductID.Text = "";
                ((DataTable)ViewState["dt"]).Clear();//清空表中的数据
                this.GridView1.DataSource = (DataTable)ViewState["dt"];
                this.GridView1.DataBind();
            }
            catch (Exception ex)
            {
                sqlaccess.Rollback();
                Methods.AjaxMessageBox(this, "保存的过程中出现异常!");
                LogManager.Write(this, ex.Message);
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #14
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            Label        txtID = (Label)this.GridView1.Rows[e.RowIndex].FindControl("txtID");
            CheckBoxList ckl   = (CheckBoxList)this.GridView1.Rows[e.RowIndex].FindControl("ckblstRight");

            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                string strdel = "delete TRE_Employee_Role where EmployeeID='" + txtID.Text + "'";
                sqlaccess.ExecuteQuerry(strdel);
                LogManager.WriteOprationLog(SessionUser.DetailInfo, strdel);

                foreach (ListItem item in ckl.Items)
                {
                    if (item.Selected)
                    {
                        string insertStr = "insert into TRE_Employee_Role (EmployeeID,Role) values ('" + txtID.Text + "','" + item.Value + "')";
                        sqlaccess.ExecuteQuerry(insertStr);
                        LogManager.WriteOprationLog(SessionUser.DetailInfo, insertStr);
                    }
                }

                sqlaccess.Commit();
                this.GridView1.EditIndex = -1;
                this.lblMsg.Visible      = false;
                this.GridBind();
            }
            catch (Exception ex)
            {
                LogManager.Write(this, ex.Message);
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #15
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ViewState["tmpPid"] == null || ViewState["tmpPid"].ToString() == string.Empty)
                {
                    Methods.AjaxMessageBox(this, "无产品序列号,不能完成操作!"); return;
                }
                if (this.lblFindTime.Text.Trim() == string.Empty)
                {
                    Methods.AjaxMessageBox(this, "无发现时间,不能完成操作!"); return;
                }

                sqlaccess.Open();

                sqlaccess.BeginTransaction();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "INSERT INTO TB_ProcedureHistory(ProductID, Process, EmployeeID, " +
                                  "Result, [Exception], Data, DataID, Dispatch, BeginTime, EndTime) " +
                                  "VALUES (@ProductID, @Process, @EmployeeID, @Result, @Exception, " +
                                  "@Data, @DataID, @Dispatch, @BeginTime, @EndTime)";
                cmd.Parameters.Clear();
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ProductID", System.Data.SqlDbType.VarChar, 50));
                cmd.Parameters["@ProductID"].Value = ViewState["tmpPid"].ToString();
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Process", System.Data.SqlDbType.VarChar, 50));
                cmd.Parameters["@Process"].Value = "批准复检";
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EmployeeID", System.Data.SqlDbType.VarChar, 50));
                cmd.Parameters["@EmployeeID"].Value = SessionUser.ID;
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Result", System.Data.SqlDbType.Int, 50));
                cmd.Parameters["@Result"].Value = 0;
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Exception", System.Data.SqlDbType.VarChar, 2000));
                cmd.Parameters["@Exception"].Value = "";
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Data", System.Data.SqlDbType.Text));
                cmd.Parameters["@Data"].Value = "";
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@DataID", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters["@DataID"].Value = Guid.NewGuid();
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Dispatch", System.Data.SqlDbType.VarChar, 2000));
                cmd.Parameters["@Dispatch"].Value = "";
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BeginTime", System.Data.SqlDbType.DateTime));
                cmd.Parameters["@BeginTime"].Value = DateTime.Now;
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EndTime", System.Data.SqlDbType.DateTime));
                cmd.Parameters["@EndTime"].Value = DateTime.Now;

                sqlaccess.ExecuteQuerry(cmd);

                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@p1", ViewState["tmpPid"].ToString());
                cmd.Parameters.AddWithValue("@p2", this.lblEProcess.Text);

                cmd.CommandText = "delete TB_ProcedureState where productid=@p1 and process=@p2";
                sqlaccess.ExecuteQuerry(cmd);

                sqlaccess.Commit();

                this.lblEProcess.Text  = "";
                this.lblFinder.Text    = "";
                this.lblFinderID.Text  = "";
                this.lblFindTime.Text  = "";
                this.lblException.Text = "";
                this.ctrlEnable(false);
            }
            catch (Exception ex)
            {
                LogManager.Write("", ex.Message);
                Methods.AjaxMessageBox(this, ex.Message); return;
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #16
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            sqlaccess.Open();
            sqlaccess.BeginTransaction();
            try
            {
                TreeNode node = this.TreeView1.SelectedNode;
                if (node == null)
                {
                    Methods.AjaxMessageBox(this, "请先选择一个产品或部件节点!"); return;
                }
                string     logStr  = "";
                string     ModelID = node.Value;
                SqlCommand cmd     = new SqlCommand();

                //不许添加本级节点
                if (ModelID == this.txtID.Text.Trim())
                {
                    Methods.AjaxMessageBox(this, "请点放大镜图标选择可用于添加的下级节点!"); return;
                }
                //数量必须大于0
                int i = 0;
                try
                {
                    i = Convert.ToInt32(this.txtOutput.Text.Trim());
                }
                catch
                {
                    i = 0;
                }
                if (i <= 0)
                {
                    Methods.AjaxMessageBox(this, "数量必须大于0!"); return;
                }
                //不准重复添加

                for (i = 0; i < node.ChildNodes.Count; i++)
                {
                    if (this.txtID.Text.Trim() == node.ChildNodes[i].Value)
                    {
                        Methods.AjaxMessageBox(this, "已经包含了此节点!"); return;
                    }
                }


                cmd.Parameters.AddWithValue("@p1", ModelID);
                cmd.Parameters.AddWithValue("@p2", this.txtID.Text.Trim());
                cmd.Parameters.AddWithValue("@p3", this.txtOutput.Text.Trim());
                cmd.CommandText = "insert into ta_structure (ID,ItemID,Amount) values (@p1,@p2,@p3)";

                sqlaccess.ExecuteQuerry(cmd);
                sqlaccess.Commit();

                logStr = "insert into ta_structure (ID,ItemID,Amount) values ('{0}','{1}','{2}')";
                logStr = String.Format(logStr, ModelID, this.txtID.Text.Trim(), this.txtOutput.Text.Trim());
                logStr = "新增产品结构定义[" + ModelID + "] ## " + logStr;
                Methods.WriteOprationLog(SessionUser.ID, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logStr);
                GridView1_SelectedIndexChanged(null, null);
            }
            catch (Exception ex)
            {
                sqlaccess.Rollback();
                Methods.AjaxMessageBox(this, "添加操作出错!");
                LogManager.Write(this, ex.Message);
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #17
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ViewState["tmpPid"] == null || ViewState["tmpPid"].ToString() == string.Empty)
                {
                    Methods.AjaxMessageBox(this, "无产品序列号,不能完成操作!"); return;
                }
                if (this.lblFindTime.Text.Trim() == string.Empty)
                {
                    Methods.AjaxMessageBox(this, "无发现时间,不能完成操作!"); return;
                }
                if (this.txtBugType.Text.Trim() == string.Empty)
                {
                    Methods.AjaxMessageBox(this, "请输入缺陷类别!"); return;
                }
                if (this.txtBugPoint.Text.Trim() == string.Empty)
                {
                    Methods.AjaxMessageBox(this, "请输入缺陷定位点品号!"); return;
                }
                if (this.txtBugPosition.Text.Trim() == string.Empty)
                {
                    Methods.AjaxMessageBox(this, "请输入缺陷定位点位号!"); return;
                }
                if (ddlReInP == null || ddlReInP.Items.Count == 0)
                {
                    Methods.AjaxMessageBox(this, "无重入工序,无法完成操作!"); return;
                }
                if (txtRPInfo.Text.Trim() == string.Empty)
                {
                    Methods.AjaxMessageBox(this, "请输入修理信息!"); return;
                }

                sqlaccess.Open();

                sqlaccess.BeginTransaction();
                SqlCommand cmd = new SqlCommand();
                cmd.Parameters.AddWithValue("@p1", ViewState["tmpPid"].ToString());
                cmd.Parameters.AddWithValue("@p2", this.lblFindTime.Text.Trim());
                cmd.Parameters.AddWithValue("@p3", this.lblEProcess.Text.Trim());
                cmd.Parameters.AddWithValue("@p4", this.lblFinderID.Text.Trim());
                cmd.Parameters.AddWithValue("@p5", this.lblException.Text.Trim());
                cmd.Parameters.AddWithValue("@p6", this.txtBugType.Text.Trim());
                cmd.Parameters.AddWithValue("@p7", this.txtBugPoint.Text.Trim() + "[" + this.txtBugPosition.Text.Trim().ToUpper() + "]");
                cmd.Parameters.AddWithValue("@p8", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                cmd.Parameters.AddWithValue("@p9", SessionUser.ID);
                cmd.Parameters.AddWithValue("@p10", this.txtRPInfo.Text.Trim());


                cmd.CommandText = "INSERT INTO TB_RepairRecord"
                                  + " (ProductID, DetectTime, DetectProcess, DetectEmployeeID, Exception, BugID,"
                                  + " BugPointCode, RepairTime, RepairEmployeeID, RepairInfo) VALUES (@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8,@p9,@p10)";

                sqlaccess.ExecuteQuerry(cmd);

                //在流程历史表中记录维修工序信息
                cmd.CommandText = "INSERT INTO TB_ProcedureHistory(ProductID, Process, EmployeeID, " +
                                  "Result, [Exception], Data, DataID, Dispatch, BeginTime, EndTime) " +
                                  "VALUES (@ProductID, @Process, @EmployeeID, @Result, @Exception, " +
                                  "@Data, @DataID, @Dispatch, @BeginTime, @EndTime)";
                cmd.Parameters.Clear();
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@ProductID", System.Data.SqlDbType.VarChar, 50));
                cmd.Parameters["@ProductID"].Value = ViewState["tmpPid"].ToString();
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Process", System.Data.SqlDbType.VarChar, 50));
                cmd.Parameters["@Process"].Value = "返修";
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EmployeeID", System.Data.SqlDbType.VarChar, 50));
                cmd.Parameters["@EmployeeID"].Value = SessionUser.ID;
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Result", System.Data.SqlDbType.Int, 50));
                cmd.Parameters["@Result"].Value = 0;
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Exception", System.Data.SqlDbType.VarChar, 2000));
                cmd.Parameters["@Exception"].Value = "";
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Data", System.Data.SqlDbType.Text));
                cmd.Parameters["@Data"].Value = "";
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@DataID", System.Data.SqlDbType.UniqueIdentifier));
                cmd.Parameters["@DataID"].Value = Guid.NewGuid();
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Dispatch", System.Data.SqlDbType.VarChar, 2000));
                cmd.Parameters["@Dispatch"].Value = "";
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@BeginTime", System.Data.SqlDbType.DateTime));
                cmd.Parameters["@BeginTime"].Value = DateTime.Now;
                cmd.Parameters.Add(new System.Data.SqlClient.SqlParameter("@EndTime", System.Data.SqlDbType.DateTime));
                cmd.Parameters["@EndTime"].Value = DateTime.Now;

                sqlaccess.ExecuteQuerry(cmd);

                //sqlaccess.ExecuteQuerry(" update tb_ProcedureHistory set result=0 where ");//这里有? 更新到维修记录TB_RepairRecord表中,历史记录 中的result字段如何更新 置为0 还是保持原来的1
                DropDownList ddlDel = new DropDownList();

                Methods.findNextProcedure(this.ddlReInP.SelectedItem.Text, (int)ViewState["tmpProcedureID"], ddlDel);

                for (int i = 0; i < ddlDel.Items.Count; i++)
                {
                    cmd.Parameters.Clear();
                    cmd.Parameters.AddWithValue("@p1", ViewState["tmpPid"].ToString());
                    cmd.Parameters.AddWithValue("@p2", ddlDel.Items[i].Text);

                    cmd.CommandText = "delete TB_ProcedureState where productid=@p1 and process=@p2";
                    sqlaccess.ExecuteQuerry(cmd);
                }

                sqlaccess.Commit();

                this.GridBind(ViewState["tmpPid"].ToString());
            }
            catch (Exception ex)
            {
                LogManager.Write("", ex.Message);
                Methods.AjaxMessageBox(this, "已存在相同记录!"); return;
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #18
0
        protected void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                if (ViewState["pModelID"] != null && ViewState["pModelID"].ToString() != string.Empty)
                {
                    sqlaccess.Open();
                    sqlaccess.BeginTransaction();
                    SqlCommand cmd = new SqlCommand();

                    if (this.ddlop.SelectedValue == "3")//删除时
                    {
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@p1", ViewState["planid"]);
                        cmd.Parameters.AddWithValue("@p2", this.ddlop.SelectedValue);
                        cmd.Parameters.AddWithValue("@p3", System.DateTime.Now);
                        cmd.CommandText = "update ta_plan set State=@p2, CloseTime=@p3 where id=@p1";
                        sqlaccess.ExecuteQuerry(cmd);

                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@p1", ViewState["planid"]);
                        cmd.CommandText = "delete TC_PlanProcedure where planid=@p1";
                        sqlaccess.ExecuteQuerry(cmd);

                        sqlaccess.Commit();
                        string strLog = "关闭计划单[" + ViewState["planid"].ToString() + "] ## ";
                        Methods.WriteOprationLog(SessionUser.ID, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), strLog + "update ta_plan set State=3 where id=" + ViewState["planid"].ToString() + ";delete TC_PlanProcedure where planid='" + ViewState["planid"].ToString() + "'");
                        Methods.Write(this, "window.parent.closeit();window.parent.query()"); return;
                    }
                    string logstr = "";
                    if (this.rblProductModel.SelectedIndex != -1)
                    {
                        //更新计划激活状态
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@p1", ViewState["planid"]);
                        cmd.Parameters.AddWithValue("@p2", this.ddlop.SelectedValue);
                        cmd.CommandText = "update ta_plan set State=@p2 where id=@p1";
                        sqlaccess.ExecuteQuerry(cmd);

                        //产品工艺流程发生变化
                        if (rblProductModelOld.Text != rblProductModel.Items[rblProductModel.SelectedIndex].Value)
                        {
                            string sql = "SELECT ID FROM TA_Product"
                                         + " WHERE PlanID = '" + ViewState["planid"].ToString()
                                         + "' AND ModelID='" + this.lblProductModel.Text + "'";
                            DataSet tmpDS = Methods.getInforBySql(sql);
                            if (tmpDS != null && tmpDS.Tables[0].Rows.Count > 0)
                            {
                                string tmpProductID;
                                string oMsg;
                                WSProcedureCtrl.ProcedureCtrl c = new MCSApp.WSProcedureCtrl.ProcedureCtrl();
                                for (int i = 0; i < tmpDS.Tables[0].Rows.Count; i++)
                                {
                                    //发生了流程变更的产品序列号
                                    tmpProductID = tmpDS.Tables[0].Rows[i][0].ToString();
                                    //创建一条流程变更的工序历史记录
                                    c.SaveProcessPurely(tmpProductID, "变更工艺流程", SessionUser.ID, 2, "", "", DateTime.Now, DateTime.Now, out oMsg);
                                }
                                c.Dispose();
                            }
                            tmpDS.Dispose();
                        }

                        //更新计划选定的产品工艺流程
                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@p1", ViewState["planid"]);
                        cmd.Parameters.AddWithValue("@p2", ViewState["pModelID"]);
                        cmd.CommandText = "delete TC_PlanProcedure where planid = @p1 AND ModelID = @p2";
                        sqlaccess.ExecuteQuerry(cmd);

                        cmd.Parameters.Clear();
                        cmd.Parameters.AddWithValue("@p1", ViewState["planid"]);
                        cmd.Parameters.AddWithValue("@p2", ViewState["pModelID"]);
                        cmd.Parameters.AddWithValue("@p3", this.rblProductModel.SelectedValue);
                        cmd.CommandText = "insert into TC_PlanProcedure (planid,modelid,procedureid) values (@p1,@p2,@p3)";
                        sqlaccess.ExecuteQuerry(cmd);

                        logstr = "delete TC_PlanProcedure where planid='" + ViewState["planid"].ToString()
                                 + "';insert into TC_PlanProcedure (planid,modelid,procedureid) values ('" + ViewState["planid"].ToString() + "','"
                                 + ViewState["pModelID"].ToString() + "','" + this.rblProductModel.SelectedValue + "');";

                        //逐项处理部件工艺流程
                        for (int i = 0; i < this.GridView1.Rows.Count; i++)
                        {
                            RadioButtonList rbl       = (RadioButtonList)this.GridView1.Rows[i].FindControl("rblComModel");
                            Label           lblitemid = (Label)this.GridView1.Rows[i].FindControl("lblitemid");
                            Label           rblOld    = (Label)this.GridView1.Rows[i].FindControl("rblComModelOld");

                            if (rbl != null && rbl.SelectedIndex != -1)
                            {
                                //部件工艺流程发生变化
                                if (rblOld.Text != rbl.Items[rbl.SelectedIndex].Value)
                                {
                                    string sql = "SELECT ID FROM TA_Product"
                                                 + " WHERE PlanID = '" + ViewState["planid"].ToString()
                                                 + "' AND ModelID='" + lblitemid.Text + "'";
                                    DataSet tmpDS = Methods.getInforBySql(sql);
                                    if (tmpDS != null && tmpDS.Tables[0].Rows.Count > 0)
                                    {
                                        string tmpProductID;
                                        string oMsg;
                                        WSProcedureCtrl.ProcedureCtrl c = new MCSApp.WSProcedureCtrl.ProcedureCtrl();
                                        for (int j = 0; j < tmpDS.Tables[0].Rows.Count; j++)
                                        {
                                            //发生了流程变更的产品序列号
                                            tmpProductID = tmpDS.Tables[0].Rows[j][0].ToString();
                                            //创建一条流程变更的工序历史记录
                                            c.SaveProcessPurely(tmpProductID, "变更工艺流程", SessionUser.ID, 2, "", "", DateTime.Now, DateTime.Now, out oMsg);
                                        }
                                        c.Dispose();
                                    }
                                    tmpDS.Dispose();
                                }

                                //更新计划选定的部件工艺流程
                                cmd.Parameters.Clear();
                                cmd.Parameters.AddWithValue("@p1", ViewState["planid"]);
                                cmd.Parameters.AddWithValue("@p2", lblitemid.Text);
                                cmd.CommandText = "delete TC_PlanProcedure where planid = @p1 AND ModelID = @p2";
                                sqlaccess.ExecuteQuerry(cmd);

                                cmd.Parameters.Clear();
                                cmd.Parameters.AddWithValue("@p1", ViewState["planid"]);
                                cmd.Parameters.AddWithValue("@p2", lblitemid.Text);
                                cmd.Parameters.AddWithValue("@p3", rbl.SelectedValue);
                                cmd.CommandText = "insert into TC_PlanProcedure (planid,modelid,procedureid) values (@p1,@p2,@p3)";
                                sqlaccess.ExecuteQuerry(cmd);

                                logstr = logstr + "insert into TC_PlanProcedure (planid,modelid,procedureid) values ('" + ViewState["planid"].ToString()
                                         + "','" + lblitemid.Text + "','" + rbl.SelectedValue + "')";
                            }
                        }
                    }
                    else
                    {
                        Methods.AjaxMessageBox(this, "请选择产品的流程!");
                    }
                    sqlaccess.Commit();
                    if (logstr != "")
                    {
                        string strLog = "激活计划单[" + ViewState["planid"].ToString() + "] ## ";
                        Methods.WriteOprationLog(SessionUser.ID, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), strLog + logstr);
                    }
                    Methods.Write(this, "window.parent.closeit();window.parent.query()");
                }
            }
            catch (Exception ex)
            {
                LogManager.Write(this, ex.Message);
                Methods.AjaxMessageBox(this, "保存流程到计划流程表时出现异常!可能是由于添加重复记录!");
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #19
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (this.TreeView1.Nodes.Count == 0)
            {
                Methods.AjaxMessageBox(this, "无数据要保存!"); return;
            }
            sqlaccess.Open();
            sqlaccess.BeginTransaction();
            SqlCommand cmd = new SqlCommand();

            try
            {
                string Groupid = "";
                //DataSet tmpds= Methods.getInforBySql("select id from ta_group where LeaderID='"+SessionUser.ID+"'");//?会不会有计划不同时 出现重复记录呢

                //if (tmpds != null && tmpds.Tables[0].Rows.Count > 0)
                //{
                //    Groupid=tmpds.Tables[0].Rows[0][0].ToString();
                //}
                if (this.GridView1.Rows.Count != 0 && this.GridView1.SelectedIndex != -1)
                {
                    Groupid = this.GridView1.DataKeys[this.GridView1.SelectedIndex].Value.ToString();
                }
                else
                {
                    Methods.AjaxMessageBox(this, "请选择相应的班组!"); return;
                }

                string ModelID = "";
                if (this.TreeView1.Nodes.Count > 0)
                {
                    ModelID = this.TreeView1.Nodes[0].Value;
                }
                if (this.TreeView1.Nodes.Count > 0)
                {
                    cmd.Parameters.AddWithValue("@p1", Groupid);
                    cmd.Parameters.AddWithValue("@p2", ModelID);

                    cmd.CommandText = "delete TB_GroupMateriel where GroupID=@p1 and ModelID=@p2";
                    sqlaccess.ExecuteQuerry(cmd);

                    TreeNode root = this.TreeView1.Nodes[0];
                    foreach (TreeNode node in root.ChildNodes)
                    {
                        if (node.Target != "")
                        {
                            cmd.Parameters.Clear();
                            cmd.Parameters.AddWithValue("@p1", Groupid);
                            cmd.Parameters.AddWithValue("@p2", ModelID);
                            cmd.Parameters.AddWithValue("@p3", node.Target);//取值

                            cmd.CommandText = "insert into TB_GroupMateriel (GroupID,ModelID,MaterielID) values (@p1,@p2,@p3)";
                            sqlaccess.ExecuteQuerry(cmd);
                        }
                    }
                }

                sqlaccess.Commit();
                //btnOK_Click(null,null);//在树上体现变化
                //让树消失更合理些 能体现变化
                this.TreeView1.Nodes.Clear();
                this.txtMaterialCode.Text = "";
                this.txtModelID.Text      = "";
            }
            catch (Exception ex)
            {
                sqlaccess.Rollback();
                Methods.AjaxMessageBox(this, "在操作数据时出现异常!");
                LogManager.Write(this, ex.Message);
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #20
0
        /// <summary>
        /// 删除时触发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            if (this.GridView1.EditIndex != -1)
            {
                this.lblMsg.Visible = true;
                return;
            }
            Label lbl = (Label)this.GridView1.Rows[e.RowIndex].Cells[0].FindControl("lblid");//强行转换为lable控件



            try
            {
                string sql = "select ModelID from dbo.TC_PlanProcedure where ProcedureID=" + lbl.Text;
                sqlaccess.Open();
                string ModelId = sqlaccess.OpenQuerry(sql).Tables[0].Rows[0][0].ToString();
                sqlaccess.Close();
                string sql2 = "select * from dbo.TB_ProcedureHistory where ProductID like '" + ModelId + "%'";
                sqlaccess.Open();
                if (sqlaccess.OpenQuerry(sql2).Tables[0].Rows.Count > 0)
                {
                    Methods.AjaxMessageBox(this, "该流程已进行,无法删除!");
                    return;
                }
            }
            catch { }



            string delstr = "delete from TA_Procedure  where id='" + lbl.Text + "'";//取编号值

            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                sqlaccess.ExecuteQuerry(delstr);
                //string logStr = delstr;
                //Methods.WriteOprationLog(SessionUser.ID, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logStr);

                sqlaccess.Commit();
                //LogManager.WriteOprationLog(SessionUser.DetailInfo, delstr);
                this.GridView1.EditIndex = -1;
                this.lblMsg.Visible      = false;
                //删除后重新绑定
                this.GridBind();
            }
            catch (Exception ex)
            {
                if (ex.GetType().ToString().Equals("System.Data.SqlClient.SqlException") && ((SqlException)ex).ErrorCode == -2146232060)
                {
                    sqlaccess.Rollback();
                    this.lblMsg.Text    = "尚有其它表的记录与它相关联,不能删除!";
                    this.lblMsg.Visible = true;
                }
                else
                {
                    LogManager.Write(this, ex.ToString());
                }
            }
            finally
            {
                sqlaccess.Close();
            }
        }
コード例 #21
0
        protected void btnSaveRcd_Click(object sender, EventArgs e)
        {
            int Len = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["MIDLenInSN"]);

            if (this.txtOldModelID.Text.Trim().Length != Len || this.txtNewModelID.Text.Trim().Length != Len)
            {
                Methods.AjaxMessageBox(this, "输入的产品品号不合法");
                return;
            }

            if (this.txtOldModelID.Text.Trim() == this.txtNewModelID.Text.Trim())
            {
                Methods.AjaxMessageBox(this, "新品号不应与旧品号相同!"); return;
            }

            string mid1 = this.txtOldModelID.Text.Trim().Substring(0, Len - 3);
            string mid2 = this.txtNewModelID.Text.Trim().Substring(0, Len - 3);

            if (mid1 != mid2)
            {
                Methods.AjaxMessageBox(this, "新品号与旧品号不一致!");
                return;
            }

            try
            {
                DataTable dt = (DataTable)ViewState["dt"];
                sqlaccess.Open();
                StringBuilder sb = new StringBuilder();
                sb.Append("SELECT ID FROM TA_Model where ID ='" + this.txtOldModelID.Text.Trim() + "' AND (ModelType = 1)");

                ds = sqlaccess.OpenQuerry(sb.ToString());
                if (ds != null && ds.Tables[0].Rows.Count > 0)
                {
                }
                else
                {
                    Methods.AjaxMessageBox(this, "输入的旧产品品号在数据库中不存在!");
                    return;
                }
            }
            catch (Exception ex)
            {
                LogManager.Write(this, ex.Message);
            }
            finally
            {
                sqlaccess.Close();
            }

            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "INSERT INTO TA_Model(ID, Name, Code, CustomerID, ModelType) " +
                                  "SELECT @NewModelID AS id, Name, Code, CustomerID, ModelType FROM TA_Model " +
                                  "WHERE (ID = @OldModelID) AND (ModelType = 1)";
                cmd.Parameters.Clear();
                cmd.Parameters.AddWithValue("@NewModelID", this.txtNewModelID.Text.Trim());
                cmd.Parameters.AddWithValue("@OldModelID", this.txtOldModelID.Text.Trim());

                sqlaccess.ExecuteQuerry(cmd);

                cmd.CommandText = "INSERT INTO TA_Structure(ID, ItemID, Amount) " +
                                  "SELECT @NewModelID AS id, ItemID, Amount FROM TA_Structure WHERE (ID = @OldModelID)";
                sqlaccess.ExecuteQuerry(cmd);

                sqlaccess.Commit();
                this.txtNewModelID.Text = "";

                Methods.AjaxMessageBox(this, "已创建新产品品号,并继承了旧产品的结构表,可以在“产品结构定义”中做相应修改");
            }
            catch (Exception ex)
            {
                sqlaccess.Rollback();
                Methods.AjaxMessageBox(this, "保存的过程中出现异常!");
                LogManager.Write(this, ex.Message);
            }
            finally
            {
                sqlaccess.Close();
            }
        }