protected void btnAdd_Click(object sender, EventArgs e) { string strCODE; try { if (string.IsNullOrEmpty(SLP_VENDOR.Text.Trim()) || string.IsNullOrEmpty(DDL_PAY_KIND.SelectedValue) || string.IsNullOrEmpty(DDL_TRAN_CORP.SelectedValue)) { ErrorMsgLabel.Text = "供應商代號、商品收費方式、轉運商運費 需有值"; return; } DataTable dt = ItemData.GetChanges(DataRowState.Deleted); int inCount = (dt == null ? 0 : dt.Rows.Count); if ((DDL_PAY_KIND.SelectedValue == "1" || DDL_PAY_KIND.SelectedValue == "2")) { if (ItemData.Rows.Count > 0) { if (inCount != ItemData.Rows.Count) { ErrorMsgLabel.Text = "商品收費方式若為【全部要收】或【全部不收】,則不需設定明細資料,請先將所有品項刪除"; return; } } } else { if (ItemData.Rows.Count > 0) { if (inCount == ItemData.Rows.Count) { ErrorMsgLabel.Text = "商品收費方式如為單品要收或單品不收,就需設定明細資料。"; return; } } else { ErrorMsgLabel.Text = "商品收費方式如為單品要收或單品不收,就需設定明細資料"; return; } } ArrayList parameterList = new ArrayList(); parameterList.Clear(); ArrayList masterParameter = new ArrayList(); CAMCommon bco1 = new CAMCommon(); masterParameter.Add(bco1.GetValueSetParameter(SLP_VENDOR.Text, "string", false)); //0 masterParameter.Add(bco1.GetValueSetParameter(DDL_PAY_KIND.SelectedValue, "string", false)); //1 masterParameter.Add(bco1.GetValueSetParameter(DDL_TRAN_CORP.SelectedValue, "string", false)); //2 masterParameter.Add(bco1.GetValueSetParameter(Session["UID"].ToString(), "string", false)); //3 string strITEM = string.Empty; for (int i = 0; i < ItemData.Rows.Count; i++) { if (ItemData.Rows[i].RowState != DataRowState.Deleted) { ArrayList detailParameter = new ArrayList(); detailParameter.Add(bco1.GetValueSetParameter(ItemData.Rows[i]["ITEM"].ToString(), "string", false)); detailParameter.Add(bco1.GetValueSetParameter(Session["UID"].ToString(), "string", false)); parameterList.Add(detailParameter); } } VAM24_BCO bco = new VAM24_BCO(ConnectionDB); string[] strReturn = bco.CreateTranShip(masterParameter, parameterList); if (strReturn[2] == "") { strCODE = strReturn[1]; //ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('新增成功');location.replace('VAM242.aspx?Code=" + Request["Code"].ToString() + "&Mode=View&ID=" + strCODE + "');"), true); ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('新增成功');location.replace('VAM241.aspx?Code=" + Request["Code"].ToString() + "');"), true); } else { this.ErrorMsgLabel.Text = "新增失敗:" + strReturn[2]; return; } } catch (Exception ex) { WaringLogProcess(ex.Message); this.ErrorMsgLabel.Text = ex.Message.Split(Environment.NewLine.Replace(Environment.NewLine, "~").ToCharArray())[0]; //直接取第一個 } finally { Finally_Function(); } }