Пример #1
0
        /// <summary>
        /// 编辑时触发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            if (this.GridView1.EditIndex != -1)
            {
                this.lblMsg.Visible = true;
                return;
            }

            this.GridView1.EditIndex = e.NewEditIndex;
            this.GridBind();

            TextBox txtid = (TextBox)this.GridView1.Rows[e.NewEditIndex].FindControl("txtid");

            txtid.Enabled = false; txtid.Enabled = false;


            Coolite.Ext.Web.ComboBox ComboBox1 = (Coolite.Ext.Web.ComboBox) this.GridView1.Rows[e.NewEditIndex].FindControl("ComboBox1");
            ComboBox1.Visible = false;


            DropDownList ddlPlanType = (DropDownList)this.GridView1.Rows[e.NewEditIndex].FindControl("ddlPlanType");//用户名称标签
            Label        lblPlanType = (Label)this.GridView1.Rows[e.NewEditIndex].FindControl("lblPlanType");

            ddlPlanType.SelectedIndex = ddlPlanType.Items.IndexOf(ddlPlanType.Items.FindByValue(lblPlanType.Text));
        }
Пример #2
0
        /// <summary>
        /// 编辑时触发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
        {
            if (this.GridView1.EditIndex != -1)
            {
                this.lblMsg.Visible = true;
                return;
            }

            this.GridView1.EditIndex = e.NewEditIndex;
            this.GridBind();

            //DropDownList ddlstate = (DropDownList)this.GridView1.Rows[e.NewEditIndex].FindControl("ddlModelType");
            //ddlstate.SelectedValue = this.GridView1.DataKeys[e.NewEditIndex].Value.ToString();
            TextBox txtModelID = (TextBox)this.GridView1.Rows[e.NewEditIndex].FindControl("txtModelID");

            Coolite.Ext.Web.ComboBox ComboBox1 = (Coolite.Ext.Web.ComboBox) this.GridView1.Rows[e.NewEditIndex].FindControl("ComboBox1");

            txtModelID.Enabled = false;
            ComboBox1.Visible  = false;
        }
Пример #3
0
        /// <summary>
        /// 更新时触发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string  id         = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
            TextBox txtid      = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtid");
            TextBox txtModelID = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtModelID");
            TextBox txtOutput  = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtOutput");
            TextBox txtOrderID = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtOrderID");
            //TextBox txtPlanType = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtPlanType");
            DropDownList ddlPlanType = (DropDownList)this.GridView1.Rows[e.RowIndex].FindControl("ddlPlanType");
            TextBox      txtremark   = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtremark");

            if (id != null && id != string.Empty)
            {
                if (!Methods.ModelIDIsInDB(txtModelID.Text.Trim()))
                {
                    Methods.AjaxMessageBox(this, "输入的品号无效!"); return;
                }
            }
            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                if (id != null && id != string.Empty)
                {
                    SqlCommand cmd = new SqlCommand();

                    cmd.Parameters.AddWithValue("@p1", txtid.Text.Trim());
                    cmd.Parameters.AddWithValue("@p2", txtModelID.Text.Trim());
                    cmd.Parameters.AddWithValue("@p3", txtOutput.Text.Trim());
                    cmd.Parameters.AddWithValue("@p4", txtOrderID.Text.Trim());
                    //cmd.Parameters.AddWithValue("@p5",txtPlanType.Text.Trim());
                    cmd.Parameters.AddWithValue("@p5", ddlPlanType.SelectedValue);
                    cmd.Parameters.AddWithValue("@p6", txtremark.Text.Trim());
                    //cmd.Parameters.AddWithValue("@p7", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd"));
                    //cmd.Parameters.AddWithValue("@p8",1);



                    cmd.CommandText = " UPDATE TA_Plan SET  ModelID = @p2, Output = @p3, OrderID = @p4, PlanType = @p5,Remark = @p6 where ID = @p1";

                    sqlaccess.ExecuteQuerry(cmd);
                }
                else
                {
                    Coolite.Ext.Web.ComboBox ComboBox1 = (Coolite.Ext.Web.ComboBox) this.GridView1.Rows[e.RowIndex].FindControl("ComboBox1");


                    SqlCommand cmd = new SqlCommand();
                    cmd.Parameters.AddWithValue("@p1", txtid.Text.Trim());
                    cmd.Parameters.AddWithValue("@p2", ComboBox1.SelectedItem.Value.Trim());
                    cmd.Parameters.AddWithValue("@p3", txtOutput.Text.Trim());
                    cmd.Parameters.AddWithValue("@p4", txtOrderID.Text.Trim());
                    //cmd.Parameters.AddWithValue("@p5",txtPlanType.Text.Trim());
                    cmd.Parameters.AddWithValue("@p5", ddlPlanType.SelectedValue);
                    cmd.Parameters.AddWithValue("@p6", txtremark.Text.Trim());
                    cmd.Parameters.AddWithValue("@p7", System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:dd"));
                    cmd.Parameters.AddWithValue("@p8", 1);

                    cmd.CommandText = "INSERT INTO TA_Plan (ID, ModelID, Output, OrderID, PlanType, Remark, FoundTime, State) VALUES (@p1,@p2,@p3,@p4,@p5,@p6,@p7,@p8)";
                    sqlaccess.ExecuteQuerry(cmd);
                }
                sqlaccess.Commit();
                this.GridView1.EditIndex = -1;
                this.lblMsg.Visible      = false;
                this.lblAccMsg.Visible   = false;
                this.GridBind();
                ViewState["newMark"] = false;//新建清除
            }
            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();
            }
        }
Пример #4
0
        /// <summary>
        /// 更新时触发
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            //TextBox txtid = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtid");
            string  txtid   = this.GridView1.DataKeys[e.RowIndex].Value.ToString();
            TextBox txtName = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtName");
            //DropDownList ddlModelType = (DropDownList)this.GridView1.Rows[e.RowIndex].FindControl("ddlModelType");
            TextBox txtModelID = (TextBox)this.GridView1.Rows[e.RowIndex].FindControl("txtModelID");
            string  tmpsql     = "select id from ta_model where id='" + txtModelID.Text.Trim() + "'";

            ds = sqlaccess.OpenQuerry(tmpsql);
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                this.lblMsg.Visible = false;
            }
            else
            {
                if (txtid != string.Empty)
                {
                    this.lblMsg.Text    = "输入的品号在数据库中不存在!";
                    this.lblMsg.Visible = true;
                    return;
                }
            }


            try
            {
                sqlaccess.Open();
                sqlaccess.BeginTransaction();
                if (txtid != string.Empty)//非新建状态
                {
                    System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
                    cmd.Parameters.AddWithValue("@p1", txtid.Trim());
                    cmd.Parameters.AddWithValue("@p2", txtName.Text.Trim());
                    cmd.Parameters.AddWithValue("@p3", txtModelID.Text.Trim());
                    cmd.CommandText = "update TA_Procedure set name=@p2,ModelID=@p3 where id=@p1";
                    sqlaccess.ExecuteQuerry(cmd);
                    //LogManager.WriteOprationLog(SessionUser.DetailInfo, updateStr);
                    //string logStr = "update TA_Model set id ='{0}',name='{1}',ModelType='{2}',Code='{3}' where id='{4}'";
                    //logStr = String.Format(logStr, txtid.Text.Trim(), txtName.Text.Trim(), ddlModelType.SelectedValue, txtCode.Text.Trim(), txtid.Text.Trim());
                    //Methods.WriteOprationLog(SessionUser.ID, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logStr);
                }
                else//新建状态
                {
                    Coolite.Ext.Web.ComboBox ComboBox1 = (Coolite.Ext.Web.ComboBox) this.GridView1.Rows[e.RowIndex].FindControl("ComboBox1");

                    System.Data.SqlClient.SqlCommand cmd = new System.Data.SqlClient.SqlCommand();
                    //cmd.Parameters.AddWithValue("@p1", txtid.Text.Trim());
                    cmd.Parameters.AddWithValue("@p2", txtName.Text.Trim());
                    cmd.Parameters.AddWithValue("@p3", ComboBox1.SelectedItem.Value.ToString().Trim());
                    cmd.CommandText = "insert into TA_Procedure  (name,ModelID) values(@p2,@p3)";
                    sqlaccess.ExecuteQuerry(cmd);
                    //string logStr = "insert into TA_Model  (id,name,ModelType,Code) values('{0}','{1}','{2}','{3}')";
                    //logStr = String.Format(logStr, txtid.Text.Trim(), txtName.Text.Trim(), ddlModelType.SelectedValue, txtCode.Text.Trim());
                    //LogManager.WriteOprationLog(SessionUser.DetailInfo, updateStr);
                    //Methods.WriteOprationLog(SessionUser.ID, System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), logStr);
                }

                sqlaccess.Commit();
                this.GridView1.EditIndex = -1;
                this.lblMsg.Visible      = false;
                this.lblAccMsg.Visible   = false;
                this.GridBind();
            }
            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('\'', '"'));
                //}
                this.lblMsg.Text    = "更新的记录在数据库中已存在!";
                this.lblMsg.Visible = true;
                LogManager.Write(this, ex.Message);
            }
            finally
            {
                sqlaccess.Close();
            }
        }