Ejemplo n.º 1
0
    protected void BtnSendMail_Click(object sender, EventArgs e)
    {
        try
        {
            DataTable Dt1;
            DataTable Dt2;

            DataSet Ds1 = new DataSet();
            DataSet Ds2 = new DataSet();

            Dt1 = (DataTable)ViewState["MasterOLDData"];
            Dt2 = (DataTable)ViewState["AllDetailOLDData"];

            Dt2 = DT_Filter(Dt2, "(ITEM=VIRTUAL_CODE) or (ITEM<>VIRTUAL_CODE And PURCHASE_QTY<>0)");

            if (Dt2.Rows.Count == 0)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('查無明細資料或採購量未大於0!')", true);
                return;
            }

            if (txtMAIL_ADDR.Text == string.Empty)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('電子信箱無資料!')", true);
                return;            
            }

            
            ErrorMsgLabel.Text = "";
            
            #region 新增寄送的採購單資料
            ArrayList ParameterList = new ArrayList();
            ParameterList.Clear();
            ParameterList.Add(Dt1.Rows[0]["PURCHASE_NO"].ToString());
            ParameterList.Add(Session["UID"].ToString());

            MaintainPurchaseOrder bco = new MaintainPurchaseOrder(ConntionDB);

            string resault =bco.CreatePurchaseMailData(ParameterList,null);

            if (resault == "1")
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('新增寄送採購資料成功!')", true);
            }
            else
            {
                throw new Exception("新增寄送採購單資料失敗!");
            }

            #endregion

        }
        catch (Exception ex)
        { this.ErrorMsgLabel.Text = ex.Message; }
        finally { }
    }