Esempio n. 1
0
    protected void imgSave_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            if (!CheckInfo())
            {
                return;
            }
            int i = QTCKQuery.GetRecordCount(this.txtCKDH.Text);
            if (i > 0)
            {
                this.PrintfError("该单据已经执行,不能修改");
                return;
            }
            string DJZT = this.hidZT.Value.Trim();
            if (DJZT == "Add")//保存新建的单据
            {
                DataSet ds = (DataSet)Session["QTCKITEM"];
                if (ds == null || ds.Tables[0].Rows.Count < 1)
                {
                    this.PrintfError("未添加任何明细,请进行添加!");
                    return;
                }
                string  CKDH = this.txtCKDH.Text.Trim();
                string  CK   = this.drpFHCK.SelectedValue;
                string  CPH  = this.txtCPH.Text.Trim();
                string  MDD  = this.txtMDD.Text.Trim();
                string  ZDR  = this.txtZDR.Text.Trim();
                string  ZDRQ = this.txtZDRQ.Text.Trim();
                string  CKLX = this.drpCKLX.Text.Trim();
                string  NCDJ = this.txtNCDJ.Text.Trim();
                string  CYS  = this.drpCYS.SelectedValue;
                string  FYSJ = this.txtFYRQ.Text.Trim();
                string  SHDW = this.drpSHDW.Text.Trim();
                DataRow row  = ds.Tables[1].NewRow();//CKDH,CK,CKLX,NCDJ
                row["CKDH"]      = CKDH;
                row["CK"]        = CK;
                row["CPH"]       = CPH;
                row["AimAdress"] = MDD;
                row["ZDR"]       = ZDR;
                row["ZDRQ"]      = DateTime.Now;
                row["STATUS"]    = "0";
                row["CKLX"]      = CKLX;
                row["NCDJ"]      = NCDJ;
                if (CYS != "请选择")
                {
                    row["CYS"] = CYS;
                }
                row["FYSJ"] = Convert.ToDateTime(FYSJ);
                if (SHDW != "请选择" || !string.IsNullOrEmpty(SHDW))
                {
                    row["SHDW"] = SHDW;
                }
                ds.Tables[1].Rows.Add(row);

                QTCKQuery.AddQTCKD(ds);
                this.hidZT.Value = "";
                ReturnStatus();
            }
            if (DJZT == "Modify")//保存修改的单据
            {
                DataSet ds = (DataSet)Session["QTCKITEM"];
                if (ds == null || ds.Tables[0].Rows.Count < 1)
                {
                    this.PrintfError("未添加任何明细,请进行添加!");
                    return;
                }
                string CKDH = this.txtCKDH.Text.Trim();
                string CK   = this.drpFHCK.SelectedValue;
                string CPH  = this.txtCPH.Text.Trim();
                string MDD  = this.txtMDD.Text.Trim();
                string ZDR  = this.txtZDR.Text.Trim();
                string ZDRQ = this.txtZDRQ.Text.Trim();
                string CKLX = this.drpCKLX.Text.Trim();
                string NCDJ = this.txtNCDJ.Text.Trim();
                string CYS  = this.drpCYS.SelectedValue;
                string FYSJ = this.txtFYRQ.Text.Trim();
                string SHDW = this.drpSHDW.Text.Trim();
                ds.Tables[1].Rows[0]["CK"]        = CK;
                ds.Tables[1].Rows[0]["CPH"]       = CPH;
                ds.Tables[1].Rows[0]["AimAdress"] = MDD;
                ds.Tables[1].Rows[0]["ZDR"]       = ZDR;
                ds.Tables[1].Rows[0]["ZDRQ"]      = ZDRQ;
                ds.Tables[1].Rows[0]["CKLX"]      = CKLX;
                ds.Tables[1].Rows[0]["NCDJ"]      = NCDJ;
                ds.Tables[1].Rows[0]["CYS"]       = CYS;
                ds.Tables[1].Rows[0]["FYSJ"]      = FYSJ;
                ds.Tables[1].Rows[0]["SHDW"]      = SHDW;

                QTCKQuery.AddQTCKD(ds);
                this.hidZT.Value = "";
                ReturnStatus();
            }
            this.frameItem.Attributes["src"] = "QTCKD_item.aspx?ZT=Browse";
        }
        catch
        {
            this.PrintfError("保存过程出现错误,请重试");
            return;
        }
    }