Esempio n. 1
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();
        }