Example #1
0
    protected void btnDel_Click(object sender, EventArgs e)
    {
        try
        {
            string SessionIDName = "VAM271_" + PageTimeStamp.Value;
            DataTable dtA = new DataTable();
            dtA = (DataTable)Session[SessionIDName];
            LinkButton btn = sender as LinkButton;
            GridViewRow gr = (btn.BindingContainer as GridViewRow);
            int i = gr.RowIndex;
            DataRow drA = null;
            drA = dtA.Select("TRANSHIP_ID=" + int.Parse(dtA.Rows[i]["TRANSHIP_ID"].ToString()) + " And AREA_NO ='" + dtA.Rows[i]["AREA_NO"].ToString() + "'")[0];

            CAMCommon CAMCommonBCO = new CAMCommon();
            ArrayList ParameterList = new ArrayList();
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(drA["TRANSHIP_ID"].ToString(), "int", false));
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(drA["AREA_NO"].ToString(), "string", false));
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(Session["UID"].ToString(), "string", false));

            VAM27_BCO BCO = new VAM27_BCO(ConntionDB);
            string[] strResult = BCO.DeleteTranShipValue(ParameterList, null);
            if (strResult[0] == "1")
            {
                drA.Delete();
                dtA.AcceptChanges();
                Session[SessionIDName] = dtA;
                this.GridView1.DataSource = dtA;
                this.GridView1.DataBind();

                if (dtA.Rows.Count > 0)
                {
                    StringCollection sc = new StringCollection();
                    string strTRANSHIP_ID = "";
                    foreach (DataRow dr in dtA.Rows)
                    {
                        if (strTRANSHIP_ID != dr["TRANSHIP_ID"].ToString())
                        {
                            sc.Add(dr["TRANSHIP_ID"].ToString());
                        }

                        strTRANSHIP_ID = dr["TRANSHIP_ID"].ToString();
                    }

                    Session["VAM27CodeCollection"] = sc;
                }
            }

            ErrorMsgLabel.Text = strResult[1];
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
Example #2
0
    protected void DoAddDetail()
    {
        try
        {
            string strAreaNo = (SLP_AREA_NO_S1.Visible == true) ? SLP_AREA_NO_S1.Text.Trim() : SLP_AREA_NO_S2.Text.Trim();
            
            VAM27_BCO bco = new VAM27_BCO(ConnectionDB);
            ArrayList list = new ArrayList();
            list.Add(int.Parse(rblTRANSHIP.SelectedValue));
            list.Add(strAreaNo);
            list.Add(Session["UID"].ToString());
            DataTable dtDetail = bco.GetSysCodeDetl(list);
            string AreaName = dtDetail.Rows[0]["EXPLAIN"].ToString();
            
            switch (RowMode)
            {
                case RowEditMode.Add:
                    DataRow row = DetailData.NewRow();
                    row["AREA_NO"] = strAreaNo;
                    row["AREA_NAME"] = AreaName;
                    row["PRICE"] = SLP_PRICE.Text.Trim();
                    DetailData.Rows.Add(row);
                    break;
                case RowEditMode.Edit:
                    for (int i=0; i < DetailData.Rows.Count; i++)
                    {
                        if (DetailData.Rows[i].RowState != DataRowState.Deleted)
                        {
                            if (DetailData.Rows[i]["AREA_NO"].ToString() == strAreaNo)
                            {
                                DetailData.Rows[i]["PRICE"] = SLP_PRICE.Text;
                            }
                        }
                    }
                    break;
            }

            GridView1.DataSource = DetailData;
            GridView1.DataBind();

            SLP_AREA_NO_S1.Text = "";
            SLP_AREA_NO_S2.Text = "";
            pnlAddDetail.Visible = false;
            btnAddDetail.Visible = true;
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { Finally_Function(); }
    }
Example #3
0
    private void BindData()
    {
        CAMCommon CAMCommonBCO = new CAMCommon();
        ArrayList ParameterList = new ArrayList();
        ParameterList.Clear();
        ParameterList.Add(CAMCommonBCO.GetValueSetParameter((rblTRANSHIP.SelectedValue == "3") ? "" : rblTRANSHIP.SelectedValue, "int", false));

        if (rblTRANSHIP.SelectedValue == "1")
        {
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_AREA_NO_S1.Text, "string", false));
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_AREA_NO_E1.Text, "string", false));
        }
        else if (rblTRANSHIP.SelectedValue == "2")
        {
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_AREA_NO_S2.Text, "string", false));
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_AREA_NO_E2.Text, "string", false));
        }
        else if (rblTRANSHIP.SelectedValue == "3")
        {
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_AREA_NO_S3.Text, "string", false));
            ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_AREA_NO_E3.Text, "string", false));
        }

        ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_CREATEDATE.StartDate, "date", false));
        ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_CREATEDATE.EndDate, "date", false));
        ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_CREATEUID.Text, "string", false));
        ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_UPDATEDATE.StartDate, "date", false));
        ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_UPDATEDATE.EndDate, "date", false));
        ParameterList.Add(CAMCommonBCO.GetValueSetParameter(SLP_UPDATEUID.Text, "string", false));
        ParameterList.Add((TextBoxRowCountLimit.Text == "") ? "100" : (int.Parse(TextBoxRowCountLimit.Text) < 0) ? "100" : TextBoxRowCountLimit.Text);
        ParameterList.Add(CAMCommonBCO.GetValueSetParameter(Session["UID"].ToString(), "string", false));

        VAM27_BCO BCO = new VAM27_BCO(ConntionDB);
        DataTable dt = BCO.QueryTranShipValueByFind(ParameterList);

        string SessionIDName = "VAM271_" + PageTimeStamp.Value;
        Session[SessionIDName] = dt;
        GridView1.DataSource = dt;
        GridView1.PageSize = (TextBoxPagesize.Text == "") ? 20 : (int.Parse(TextBoxPagesize.Text) < 0) ? 20 : int.Parse(TextBoxPagesize.Text);
        GridView1.PageIndex = 0;
        GridView1.DataBind();

        if (dt.Rows.Count > 0)
        {
            StringCollection sc = new StringCollection();
            string strTRANSHIP_ID = "";
            foreach (DataRow dr in dt.Rows)
            {
                if (strTRANSHIP_ID != dr["TRANSHIP_ID"].ToString())
                {
                    sc.Add(dr["TRANSHIP_ID"].ToString());
                }

                strTRANSHIP_ID = dr["TRANSHIP_ID"].ToString();
            }

            Session["VAM27CodeCollection"] = sc;
        }
        else
        {
            ErrorMsgLabel.Text = "查無資料";
        }
    }
Example #4
0
    protected void btnSaveDetail_Click(object sender, EventArgs e)
    {
        try
        {
            string strAREA_NO = "";
            
            if (SLP_AREA_NO_S1.Visible == true)
            {
                if (SLP_AREA_NO_S1.Text.Trim() == "")
                {
                    ErrorMsgLabel.Text = "請輸入【轉運站代號】";
                    return;
                }
                else
                {
                    strAREA_NO = SLP_AREA_NO_S1.Text.Trim();
                }
            }

            if (SLP_AREA_NO_S2.Visible == true)
            {
                if (SLP_AREA_NO_S2.Text.Trim() == "")
                {
                    ErrorMsgLabel.Text = "請輸入【轉運站代號】";
                    return;
                }
                else
                {
                    strAREA_NO = SLP_AREA_NO_S2.Text.Trim();
                }
            }

            if (SLP_PRICE.Text.Trim() == "")
            {
                ErrorMsgLabel.Text = "請輸入【金額(元/KG)】";
                return;
            }

            if (RowMode == RowEditMode.Add)
            {
                DataRow[] dra1 = DetailData.Select(string.Format("AREA_NO = '{0}'", strAREA_NO));
                if (dra1.Length > 0)
                {
                    ErrorMsgLabel.Text = "【轉運站代號】不能重複";
                    return;
                }
            }

            string[] strResult = new string[2];
            ArrayList ParameterList = new ArrayList();
            if (OperationMode == OpMode.Add)
            {
                ParameterList.Add("Add");
            }
            else if (OperationMode == OpMode.Edit)
            {
                ParameterList.Add("Edit");
            }
            ParameterList.Add(int.Parse(rblTRANSHIP.SelectedValue));
            ParameterList.Add((SLP_AREA_NO_S1.Visible == true) ? SLP_AREA_NO_S1.Text.Trim() : SLP_AREA_NO_S2.Text.Trim());
            ParameterList.Add(Session["UID"].ToString());
            VAM27_BCO bco = new VAM27_BCO(ConnectionDB);
            strResult = bco.CheckDetail(ParameterList, null);

            if (strResult[0] == "0")
            {
                ErrorMsgLabel.Text = strResult[1];
            }
            else
            {
                DoAddDetail();
            }
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { Finally_Function(); }
    }
Example #5
0
    protected void btnAddDetail_Click(object sender, EventArgs e)
    {
        try
        {
            string[] strResult = new string[2];
            if (OperationMode == OpMode.Add)
            {
                ArrayList ParameterList = new ArrayList();
                ParameterList.Add("Add");
                ParameterList.Add(int.Parse(rblTRANSHIP.SelectedValue));
                ParameterList.Add(Session["UID"].ToString());
                VAM27_BCO bco = new VAM27_BCO(ConnectionDB);
                strResult = bco.CheckMaster(ParameterList, null);

                if (strResult[0] == "0")
                {
                    ErrorMsgLabel.Text = strResult[1];

                    return;
                }
            }

            pnlAddDetail.Visible = true;
            SLP_AREA_NO_S1.Text = "";
            SLP_AREA_NO_S2.Text = "";
            SLP_AREA_NO_S1.ReadOnly = false;
            SLP_AREA_NO_S2.ReadOnly = false;
            if (rblTRANSHIP.SelectedValue == "1")
            {
                SLP_AREA_NO_S1.Visible = true;
                SLP_AREA_NO_S2.Visible = false;
            }
            else if (rblTRANSHIP.SelectedValue == "2")
            {
                SLP_AREA_NO_S1.Visible = false;
                SLP_AREA_NO_S2.Visible = true;
            }
            SLP_PRICE.Text = "";
            btnAddDetail.Visible = false;
            RowMode = RowEditMode.Add;
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { Finally_Function(); }
    }
Example #6
0
    protected void btnModify_Click(object sender, EventArgs e)
    {
        switch (OperationMode)
        {
            case OpMode.View:
                try
                {
                    OperationMode = OpMode.Edit;
                    rblTRANSHIP.Enabled = false;
                    GridView1.Columns[3].Visible = true;

                    if (CanCreate == true)
                    {
                        btnAddDetail.Visible = true;
                    }
                    else
                    {
                        btnAddDetail.Visible = false;
                    }

                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Find, true, "VAM271.aspx?Code=" + Request["Code"].ToString(), null, WUI_GMToolbarV.ClickAction.LinkURL);

                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, true, "", btnModify, WUI_GMToolbarV.ClickAction.ButtonClick);
                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, false, "", null, WUI_GMToolbarV.ClickAction.ButtonClick);
                    GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Copy, false, "", null, WUI_GMToolbarV.ClickAction.ButtonClick);

                    GMToolbar1.GMToolbarStatus = WUI_GMToolbarV.GMToolbarStatusEnum.UpdateEdit;

                    btnModify.Text = "儲存";
                }
                catch (Exception ex)
                {
                    this.ErrorMsgLabel.Text = ex.Message;
                }
                finally { Finally_Function(); }

                break;

            case OpMode.Edit:
                try
                {
                    if (pnlAddDetail.Visible == true)
                    {
                        ErrorMsgLabel.Text = "請先將明細資料做[儲存]或[取消]";
                        return;
                    }
                    
                    //把修改寫回資料庫
                    ArrayList ParameterList = new ArrayList();
                    VAM27_BCO bco = new VAM27_BCO(ConnectionDB);

                    try
                    {
                        if (GridView1.Rows.Count == 0)
                        {
                            ErrorMsgLabel.Text = "請新增明細";
                            return;
                        }
                        else
                        {
                            for (int i = 0; i < DetailData.Rows.Count; i++)
                            {
                                if (DetailData.Rows[i].RowState != DataRowState.Deleted)
                                {
                                    ArrayList detailParameter = new ArrayList();
                                    detailParameter.Add(rblTRANSHIP.SelectedValue);
                                    detailParameter.Add(DetailData.Rows[i]["AREA_NO"].ToString());
                                    detailParameter.Add(Double.Parse(DetailData.Rows[i]["PRICE"].ToString()));
                                    detailParameter.Add(Session["UID"].ToString());
                                    ParameterList.Add(detailParameter);
                                }
                            }
                        }

                        string[] strReturn = bco.UpdateTranShipValue(ParameterList, null);
                        if (strReturn[0] == "1")
                        {
                            BindData();
                            OperationMode = OpMode.View;
                            SetControlStatus();
                            btnModify.Text = "更新";
                            
                            if (IDCollection != null)
                            {
                                if (IDCollection.Count == 1)//只有一筆
                                { GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarJustOneRecord, false, string.Empty, null, WUI_GMToolbarV.ClickAction.ButtonClick); }
                                else if (ViewState["CurrentID"].ToString() == IDCollection[0].ToString())//第一筆
                                { GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarFirstRecord, false, string.Empty, null, WUI_GMToolbarV.ClickAction.ButtonClick); }
                                else if (ViewState["CurrentID"].ToString() == IDCollection[IDCollection.Count - 1].ToString())//最後一筆
                                { GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarLastRecord, false, string.Empty, null, WUI_GMToolbarV.ClickAction.ButtonClick); }
                                else//其他
                                { GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarCenterRecord, false, string.Empty, null, WUI_GMToolbarV.ClickAction.ButtonClick); }
                            }
                            else
                            {
                                GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.NavigateBarJustOneRecord, false, string.Empty, null, WUI_GMToolbarV.ClickAction.ButtonClick);
                            }

                            GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Save, false, "", null, WUI_GMToolbarV.ClickAction.ButtonClick);
                            GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Edit, true, "", btnModify, WUI_GMToolbarV.ClickAction.ButtonClick);
                            GMToolbar1.ButtonEnableControl(WUI_GMToolbarV.ButtonType.Copy, false, "", null, WUI_GMToolbarV.ClickAction.ButtonClick);

                            this.ErrorMsgLabel.Text = "修改成功";
                        }
                        else
                        {
                            this.ErrorMsgLabel.Text = strReturn[1];
                            return;
                        }
                    }
                    catch
                    {
                        throw;
                    }
                }
                catch (Exception ex)
                {
                    this.ErrorMsgLabel.Text = ex.Message;
                }
                finally { Finally_Function(); }

                break;
        }
    }
Example #7
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        try
        {
            if (pnlAddDetail.Visible == true)
            {
                ErrorMsgLabel.Text = "請先將明細資料做[儲存]或[取消]";
                return;
            }

            ArrayList ParameterList = new ArrayList();

            if (DetailData.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "請新增明細";
                return;
            }
            else
            {
                for (int i = 0; i < DetailData.Rows.Count; i++)
                {
                    if (DetailData.Rows[i].RowState != DataRowState.Deleted)
                    {
                        ArrayList detailParameter = new ArrayList();
                        detailParameter.Add(rblTRANSHIP.SelectedValue);
                        detailParameter.Add(DetailData.Rows[i]["AREA_NO"].ToString());
                        detailParameter.Add(Double.Parse(DetailData.Rows[i]["PRICE"].ToString()));
                        detailParameter.Add(Session["UID"].ToString());
                        ParameterList.Add(detailParameter);
                    }
                }
            }

            VAM27_BCO bco = new VAM27_BCO(ConnectionDB);
            string[] strReturn = bco.CreateTranShipValue(ParameterList, null);

            if (strReturn[0] == "1")
            {
                ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "ClientScript", string.Format("alert('新增成功');location.replace('VAM272.aspx?Code=" + Request["Code"].ToString() + "&Mode=View&ID=" + rblTRANSHIP.SelectedValue + "');"), true);
            }
            else
            {
                this.ErrorMsgLabel.Text = strReturn[1];
                return;
            }
        }
        catch (Exception ex)
        {
            this.ErrorMsgLabel.Text = ex.Message;
        }
        finally { Finally_Function(); }
    }
Example #8
0
    private void BindData()
    {
        VAM27_BCO BCO = new VAM27_BCO(ConnectionDB);
        ArrayList ParameterList = new ArrayList();
        ParameterList.Add(ViewState["CurrentID"].ToString());
        ParameterList.Add(Session["UID"].ToString());

        DataTable dt = BCO.GetTranShipValue(ParameterList);

        rblTRANSHIP.SelectedValue = dt.Rows[0]["TRANSHIP_ID"].ToString();
        txtCREATEDATE.Text = DateTime.Parse(dt.Rows[0]["CREATEDATE"].ToString()).ToString("yyyy/MM/dd");
        SLP_CREATEUID.Text = dt.Rows[0]["CREATEUID"].ToString();
        txtUPDATEDATE.Text = DateTime.Parse(dt.Rows[0]["UPDATEDATE"].ToString()).ToString("yyyy/MM/dd");
        SLP_UPDATEUID.Text = dt.Rows[0]["UPDATEUID"].ToString();

        GridView1.DataSource = dt;
        GridView1.DataBind();
        DetailData = dt;
    }