Exemple #1
0
        /// <summary>
        /// 保存
        /// </summary>
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            #region 检测

            int count = 0;
            foreach (GridViewRow row in PRList.Rows)
            {
                HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck");
                if (rowCheckControl.Checked)
                {
                    count++;

                    string prDate = ((TextBox)row.FindControl("PRLPDTE")).Text.Trim();
                    if (LocalGlobal.ConvertDateFormat(prDate) <= DateTime.Today)
                    {
                        this.ShowInfoMessage("日期须在明天以后!");
                        return;
                    }
                }
            }

            if (count <= 0)
            {
                this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage"));
                return;
            }

            #endregion

            SqlConnection con = LocalGlobal.DbConnect();
            con.Open();
            SqlTransaction tran = con.BeginTransaction();//使用事务
            SqlCommand     cmd  = new SqlCommand();
            cmd.Connection  = con;
            cmd.Transaction = tran;

            var    dateModel = LocalGlobal.GetDateModel();
            string prNo      = string.Empty;

            using (PurProvider purProvider = new PurProvider())
            {
                try
                {
                    if (PRNo.Text.Trim().Length == 0)               //新增
                    {
                        prNo = purProvider.GetMaxPRNo().ToString(); //生成新的请购单号
                        if (DRAWNO.Text.Trim().Length == 0)
                        {
                            DRAWNO.Text = " ";
                        }
                    }
                    else
                    {
                        //修改请购单
                        prNo = PRNo.Text.Trim();

                        //先删除再添加
                        cmd.CommandText = purProvider.DeletePRSql(prNo);
                        cmd.ExecuteNonQuery();
                        cmd.CommandText = purProvider.DeletePRDetailSql(prNo);
                        cmd.ExecuteNonQuery();
                    }

                    #region Insert

                    cmd.CommandText = purProvider.InsertPRSql(prNo, ORDNO.Text.Trim(), DRAWNO.Text, "F", " ", "委外请购", LocalGlobal.CurrentUserID, dateModel.DateStr, LocalGlobal.CurrentUserID, dateModel.DateStr);
                    cmd.ExecuteNonQuery();

                    int seq = 0;
                    foreach (GridViewRow row in PRList.Rows)
                    {
                        HtmlInputCheckBox rowCheckControl    = (HtmlInputCheckBox)row.FindControl("RowCheck");
                        HtmlInputCheckBox urgentCheckControl = (HtmlInputCheckBox)row.FindControl("UrgentCheck");

                        if (rowCheckControl.Checked)
                        {
                            seq++;
                            string isUrgent   = urgentCheckControl.Checked ? "Y" : "N";
                            string prlstation = ((TextBox)row.FindControl("prlstation")).Text.Trim();
                            string prQty      = ((TextBox)row.FindControl("PRLQTY")).Text.Trim();
                            string prDate     = ((TextBox)row.FindControl("PRLPDTE")).Text.Trim();
                            prDate = LocalGlobal.ConvertDateFormat(prDate).ToString("yyyyMMdd");

                            cmd.CommandText = purProvider.InsertPRDetailSql(prNo, seq.ToString(), " ", prQty, prDate, prDate, "GT", ORDNO.Text.Trim(), "", row.Cells[3].Text.Trim(), prlstation, row.Cells[6].Text.Trim(), isUrgent, row.Cells[9].Text.Trim(), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr, "委外请购", row.Cells[7].Text.Trim());
                            cmd.ExecuteNonQuery();
                        }
                    }

                    #endregion

                    if (PRNo.Text.Trim().Length > 0)
                    {
                        //更新状态
                        cmd.CommandText = purProvider.UpdatePRStatusSql(prNo, "UP");
                        cmd.ExecuteNonQuery();
                    }
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    this.ShowErrorMessage("保存失败。" + error.Message);
                    return;
                }

                tran.Commit();

                PRNo.Text     = prNo;
                PRStatus.Text = LocalGlobal.GetPRStatus(prNo);
                this.BindList();
            }
        }
Exemple #2
0
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            #region 检测

            if (PRNo.Text.Trim().Length <= 0)
            {
                this.ShowWarningMessage("请输入请购单号!");
                return;
            }

            #endregion

            SqlConnection con = LocalGlobal.DbConnect();
            con.Open();
            SqlTransaction tran = con.BeginTransaction();//使用事务
            SqlCommand     cmd  = new SqlCommand();
            cmd.Connection  = con;
            cmd.Transaction = tran;

            var dateModel = LocalGlobal.GetDateModel();

            using (PurProvider purProvider = new PurProvider())
            {
                try
                {
                    bool flag = false;
                    foreach (GridViewRow row in List.Rows)
                    {
                        HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck");
                        if (rowCheckControl.Checked)
                        {
                            string seq        = row.Cells[2].Text.Trim();
                            string price      = ((TextBox)row.FindControl("prlpacst")).Text.Trim();
                            string vendorNo   = ((TextBox)row.FindControl("prlvnd")).Text.Trim();
                            string vendorName = ((TextBox)row.FindControl("prlvndm")).Text.Trim();
                            string curr       = ((TextBox)row.FindControl("prlcur")).Text.Trim();
                            string isWeight   = IsWeight.Checked ? "Y" : "";

                            #region 检测

                            if (Util.ToDecimal(price) <= 0)
                            {
                                tran.Rollback();
                                this.ShowWarningMessage("请填写单价");
                                return;
                            }
                            if (vendorNo.Length <= 0)
                            {
                                tran.Rollback();
                                this.ShowWarningMessage("请填写厂商代码");
                                return;
                            }
                            if (vendorName.Length <= 0)
                            {
                                tran.Rollback();
                                this.ShowWarningMessage("请填写厂商名称");
                                return;
                            }

                            #endregion

                            cmd.CommandText = purProvider.UpdatePRDetailSql(PRNo.Text.Trim(), seq.ToString(), price, vendorNo, vendorName, curr, isWeight, dateModel.DateStr);
                            cmd.ExecuteNonQuery();

                            flag = true;
                        }
                    }

                    if (flag)
                    {
                        //更新状态
                        cmd.CommandText = purProvider.UpdatePRStatusSql(PRNo.Text.Trim(), "UP");
                        cmd.ExecuteNonQuery();
                    }
                    else
                    {
                        this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage"));
                        tran.Rollback();
                        return;
                    }
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    this.ShowErrorMessage("保存失败。" + error.Message);
                    return;
                }

                tran.Commit();
            }

            this.BindList();
            this.PostButton.Enabled = true;
        }
Exemple #3
0
        /// <summary>
        /// 提交
        /// </summary>
        protected void PostButton_Click(object sender, EventArgs e)
        {
            #region 检测

            if (PRNo.Text.Trim().Length <= 0)
            {
                this.ShowWarningMessage("请输入请购单号!");
                return;
            }

            #endregion

            SqlConnection con = LocalGlobal.DbConnect();
            con.Open();
            SqlTransaction tran = con.BeginTransaction();//使用事务
            SqlCommand     cmd  = new SqlCommand();
            cmd.Connection  = con;
            cmd.Transaction = tran;

            using (PurProvider purProvider = new PurProvider())
            {
                try
                {
                    bool flag = false;
                    foreach (GridViewRow row in List.Rows)
                    {
                        HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck");
                        if (rowCheckControl.Checked)
                        {
                            string seq    = row.Cells[2].Text.Trim();
                            string status = row.Cells[14].Text.Trim();

                            if (status == "OK")
                            {
                                cmd.CommandText = purProvider.PostPRDetailSql(PRNo.Text.Trim(), seq.ToString());
                                cmd.ExecuteNonQuery();

                                flag = true;
                            }
                        }
                    }

                    if (flag)
                    {
                        //更新状态
                        cmd.CommandText = purProvider.UpdatePRStatusSql(PRNo.Text.Trim(), "PS");
                        cmd.ExecuteNonQuery();
                    }
                    else
                    {
                        this.ShowInfoMessage("未选中要提交的记录,请确认请购状态,或未填写价格/厂商!");
                        tran.Rollback();
                        return;
                    }
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    this.ShowErrorMessage("提交失败。" + error.Message);
                    return;
                }

                tran.Commit();
            }

            this.BindList();
        }
Exemple #4
0
        /// <summary>
        /// 保存
        /// </summary>
        protected void SaveButton_Click(object sender, EventArgs e)
        {
            var table = ViewState["ViewDT"] as DataTable;

            if (table == null || table.Rows.Count == 0)
            {
                return;
            }

            SqlConnection con = LocalGlobal.DbConnect();

            con.Open();
            SqlTransaction tran = con.BeginTransaction();//使用事务
            SqlCommand     cmd  = new SqlCommand();

            cmd.Connection  = con;
            cmd.Transaction = tran;

            var    dateModel = LocalGlobal.GetDateModel();
            string prNo      = string.Empty;

            using (PurProvider purProvider = new PurProvider())
            {
                try
                {
                    if (PRNo.Text.Trim().Length == 0)               //新增
                    {
                        prNo = purProvider.GetMaxPRNo().ToString(); //生成新的请购单号

                        cmd.CommandText = purProvider.InsertPRSql(prNo, "", "", "S", "RMB", "材料请购", LocalGlobal.CurrentUserID, dateModel.DateStr, "", "0");
                        cmd.ExecuteNonQuery();

                        PRStatus.Text = "NE";
                    }
                    else
                    {
                        //修改请购单
                        prNo = PRNo.Text.Trim();

                        //先删除再添加
                        cmd.CommandText = purProvider.DeletePRDetailSql(prNo);
                        cmd.ExecuteNonQuery();

                        //更新状态
                        cmd.CommandText = purProvider.UpdatePRStatusSql(prNo, "UP");
                        cmd.ExecuteNonQuery();

                        PRStatus.Text = "UP";
                    }

                    #region Insert

                    int seq = 0;
                    foreach (DataRow row in table.Rows)
                    {
                        seq++;

                        string prDate = row["PRLPDTE"].ToString().Trim();
                        prDate = LocalGlobal.ConvertDateFormat(prDate).ToString("yyyyMMdd");

                        cmd.CommandText = purProvider.InsertMatPRDetailSql(prNo, seq.ToString(), row["PRLQTY"].ToString().Trim(), prDate, prlwhs.Text.Trim(), row["prltno"].ToString(), row["prlstation"].ToString(), row["prlrule"].ToString(), row["prlum"].ToString(), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr, row["prlmrk"].ToString(), row["prloutno"].ToString(), row["prlpicno"].ToString());

                        cmd.ExecuteNonQuery();
                    }

                    #endregion
                }
                catch (Exception error)
                {
                    tran.Rollback();
                    this.ShowErrorMessage("保存失败。" + error.Message);
                    return;
                }

                tran.Commit();

                PRNo.Text = prNo;
                this.BindList();
            }
        }