コード例 #1
0
ファイル: CGD361.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    /// <summary>
    /// 查詢資料庫取得資料

    /// </summary> 
    private void databind()
    {
        //抓取本頁初次登記的時間

        string SessionIDName = "CGD361_" + PageTimeStamp.Value;

        CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConntionDB);

        ParameterList.Clear();
        ParameterList.Add(TextBoxCode.Text.Trim());
        ParameterList.Add(TextBoxName.Text.Trim());
        ParameterList.Add(TextBoxMain_Explain.Text.Trim());
        ParameterList.Add(TextBoxScode.Text.Trim());
        ParameterList.Add(TextBoxExplain.Text.Trim());        
        ParameterList.Add(TextBoxRowCountLimit.Text.Trim());

        DataTable Dt = BCO.QueryRow(ParameterList, CheckBoxLikeSearch.Checked);

        Session[SessionIDName] = Dt;
        GridView1.DataSource = Dt;
        //設定分頁大小
        if (TextBoxPagesize.Text == "0")
        {
            GridView1.PageSize = 1;
        }
        else
        {
            GridView1.PageSize = (TextBoxPagesize.Text == "") ? 10 : (int.Parse(TextBoxPagesize.Text) < 0) ? 10 : int.Parse(TextBoxPagesize.Text);
        }
        GridView1.PageIndex = 0;
        GridView1.DataBind();

        #region 將Key值存到Session中

        ArrayList arl_Key = new ArrayList();

        foreach (DataRow drRow in Dt.Rows)
        { arl_Key.Add("id=" + drRow["ID"].ToString()); }

        Session["CGD36_SortKey" + this.PageTimeStamp.Value] = arl_Key;

        #endregion

    }
コード例 #2
0
ファイル: CGD361.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    private void WriteToXls()
    {
        try
        {
            ErrorMsgLabel.Text = "";

            ParameterList.Clear();
            ParameterList.Add(TextBoxCode.Text.Trim());
            ParameterList.Add(TextBoxName.Text.Trim());
            ParameterList.Add(TextBoxMain_Explain.Text.Trim());
            ParameterList.Add(TextBoxScode.Text.Trim());
            ParameterList.Add(TextBoxExplain.Text.Trim());
            CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConntionDB);

            DataTable dtTemp = BCO.GET_EXPORTDATA(ParameterList, CheckBoxLikeSearch.Checked);
            if (dtTemp.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "查無可匯出資料";
            }
            else
            {
                Export_Excel(dtTemp);
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
コード例 #3
0
ファイル: CGD362.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    }//end EditCancelButton_Click
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConnectionDB);

        System.Data.Common.DbTransaction DBT = BCO.DBT_Begin();

        try
        {
            string strCode = ((HiddenField)FormView1.FindControl("hidCode")).Value.Trim();
            string strCreateDate = ((HiddenField)FormView1.FindControl("hidCreateDate")).Value.Trim();
            string strCreateUID = ((HiddenField)FormView1.FindControl("hidCreateUID")).Value.Trim();
            string strUpdateDate = ((HiddenField)FormView1.FindControl("hidUpdateDate")).Value.Trim();
            string strUpdateUID = ((HiddenField)FormView1.FindControl("hidUpdateUID")).Value.Trim();
            ParameterList.Clear();
            ParameterList.Add(strCode);
            ParameterList.Add(DBPara(strCreateDate, ParaType.Date));
            ParameterList.Add(strCreateUID);
            ParameterList.Add(DBPara(strUpdateDate, ParaType.Date));
            ParameterList.Add(strUpdateUID);
            ParameterList.Add(DateTime.Now);
            ParameterList.Add(Session["UID"].ToString());
            BCO.DEL_MAIN(ParameterList, DBT);

            ParameterList.Clear();
            ParameterList.Add(strCode);
            ParameterList.Add(DateTime.Now);
            ParameterList.Add(Session["UID"].ToString());
            BCO.DelCodeFileDTLByCode(ParameterList, DBT);

            DBT.Commit();
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "MSG", "alert('刪除完成');location.href='CGD361.aspx?code=CGD36';", true);
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
    }
コード例 #4
0
ファイル: CGD362.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    /// <summary>
    ///  編輯模式,按下更新確認鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void EditCommitButton_Click(object sender, EventArgs e)
    {
        //Trace.Warn("EditCommit");
        int UpdateRecord = 0;
        try
        {
            if (Dtl_Status != "readonly")
            {
                ErrorMsgLabel.Text = "請先將明細資料做[存檔]或[更新],再按主檔[更新]!";
            }
            else
            {

                string v_Name = ((TextBox)FormView1.FindControl("TextBoxName")).Text.Trim();
                DateTime processtime = DateTime.Now;
                string v_Explain = ((TextBox)FormView1.FindControl("TextBoxEXPLAIN")).Text.Trim();
                string v_Enable = "1";// ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_Enable")).Text.Trim();           

                DataSet Ds = new DataSet();
                DataTable Dt = dt_Result;
                if (Dt.Rows.Count == 0)
                {
                    ErrorMsgLabel.Text = "抓取不到舊值,更新失敗!";
                    return;
                }


                DataTable dtData = dt_DetailOLDData;
                for (int i = 0; i < dtData.Rows.Count; i++)
                {

                    //檢查SCODE 是否已存在Dt
                    DataRow[] ins = dtData.Select(string.Format("SCODE='{0}'", dtData.Rows[i]["SCODE"].ToString()));
                    if (ins.Length > 1)
                    {
                        ErrorMsgLabel.Text = "明細代碼重覆!";
                        return;
                    }
                }

                ParameterList.Clear();
                //舊值
                ParameterList.Add(Dt.Rows[0]["ID"]);
                ParameterList.Add(Dt.Rows[0]["CODE"]);
                ParameterList.Add(Dt.Rows[0]["NAME"]);
                ParameterList.Add(Dt.Rows[0]["CREATEDATE"]);
                ParameterList.Add(Dt.Rows[0]["CREATEUID"]);
                ParameterList.Add(Dt.Rows[0]["UPDATEDATE"]);
                ParameterList.Add(Dt.Rows[0]["UPDATEUID"]);
                ParameterList.Add(Dt.Rows[0]["ENABLE"]);
                ParameterList.Add(Dt.Rows[0]["EXPLAIN"]);

                ParameterList.Add(v_Name);
                ParameterList.Add(processtime);
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(v_Explain);
                ParameterList.Add(v_Enable);


                CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConnectionDB);

                System.Data.Common.DbTransaction DBT = BCO.DBT_Begin();

                //Update CGD_Code_MAIN
                UpdateRecord = BCO.UpdateCodeFile(ParameterList, DBT);

                //Update CGD_Code_DETL
                Update_Dtl(DBT, processtime);

                BCO.DBT_End(DBT);

                //Panel2.Visible = false;

                if (UpdateRecord == 0)
                {
                    ErrorMsgLabel.Text = "更新0筆資料!";
                    return;
                }
                else
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "CGD362", "<script>alert('更改完成');</script>");
                    ChangeFormMode(FormViewMode.ReadOnly);
                }
            }

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

            if (Dtl_Status == "insert")
            {
                this.Btn_Insert.Visible = true;
                this.Btn_Update.Visible = false;
            }
            else if (Dtl_Status == "edit")
            {
                this.Btn_Insert.Visible = false;
                this.Btn_Update.Visible = true;
            }
        }

    }
コード例 #5
0
ファイル: CGD362.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    private void Loaddata(string NewCode)
    {
        CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConnectionDB);
        ParameterList.Clear();
        ParameterList.Add(NewCode);
        DataTable Dt = BCO.QuerySwitch(CGDModel.CGD36_BCO.QueryType.ID, ParameterList);
        if (Dt != null)
        {
            if (Dt.Rows.Count == 0)
            {
                ArrayList AL = (ArrayList)Session["CGD36_SortKey" + Request.QueryString["CGD362_PageTimeStamp"]];

                string strRemove = "id=" + NewCode;
                AL.Remove(strRemove);
                Session["CGD36_SortKey" + Request.QueryString["CGD362_PageTimeStamp"]] = AL;

                ErrorMsgLabel.Text = "此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!";
            }
        }
    }
コード例 #6
0
ファイル: CGD362.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    }//end InsertCancelButton_Click


    /// <summary>
    /// 由新增模式,確認新增
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void InsertButton_Click(object sender, EventArgs e)
    {
        int AddRecord = 0;
        CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConnectionDB);
        System.Data.Common.DbTransaction DBT = BCO.DBT_Begin();
        try
        {
            if (Dtl_Status != "readonly")
            {
                ErrorMsgLabel.Text = "請先將明細資料做[存檔]或[更新],再按主檔[更新]!";
            }
            else
            {

                string v_Code = ((WUI.SLP.SLPUnique)FormView1.FindControl("TextBoxCode")).Text.Trim();
                string v_Name = ((TextBox)FormView1.FindControl("TextBoxName")).Text.Trim();
                DateTime processtime = DateTime.Now;
                string v_Explain = ((TextBox)FormView1.FindControl("TextBoxEXPLAIN")).Text.Trim();

                ParameterList.Clear();
                ParameterList.Add(v_Code);
                DataTable Dup = BCO.QuerySwitch(CGDModel.CGD36_BCO.QueryType.CODE, ParameterList);
                if (Dup.Rows.Count > 0)
                {
                    ErrorMsgLabel.Text = "代碼重覆!";
                    return;
                }

                ParameterList.Clear();
                ParameterList.Add(v_Code);
                ParameterList.Add(v_Name);
                ParameterList.Add(processtime);               //vCreateDate
                ParameterList.Add(Session["UID"].ToString()); //vCreateUID
                ParameterList.Add(processtime);               //vUpdateDate
                ParameterList.Add(Session["UID"].ToString()); //vUpdateUID
                ParameterList.Add(v_Explain);

                AddRecord = BCO.CreateCodeFile(ParameterList, DBT);

                if (AddRecord == 0)
                {
                    ErrorMsgLabel.Text = "新增0筆資料!";
                    return;
                }
                else
                {

                    DataTable dtData = dt_DetailOLDData;
                    for (int i = 0; i < dtData.Rows.Count; i++)
                    {
                        ParameterList.Clear();
                        ParameterList.Add(AddRecord); //CODE_MAIN的ID欄位
                        ParameterList.Add(processtime);
                        ParameterList.Add(Session["UID"].ToString());
                        ParameterList.Add(processtime);
                        ParameterList.Add(Session["UID"].ToString());
                        ParameterList.Add(v_Code);//CODE_MAIN的CODE欄位
                        ParameterList.Add(dtData.Rows[i]["SCODE"]);
                        ParameterList.Add(dtData.Rows[i]["EXPLAIN"]);
                        ParameterList.Add(dtData.Rows[i]["FIX_COLUMN"]);
                        BCO.CreateCodeFileDTL(ParameterList, DBT);
                    }
                    DBT.Commit();
                    Response.Write("<script>alert('新增完成');location.replace('CGD362.aspx?code=CGD36&mode=readonly&ID=" + AddRecord + "');</script>");
                }
            }
        }
        catch (Exception ex)
        {        
            ErrorMsgLabel_Insert.Text = ex.Message;
        }
    }
コード例 #7
0
ファイル: CGD362.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    }//databind_Mst

    #endregion

    /// <summary>
    /// 繫結資料 DTL
    /// </summary>
    private void databind_Dtl()
    {
        try
        {
            //ErrorMsgLabel.Text = "";
            CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConnectionDB);

            ParameterList.Clear();
            string v_Category = ((WUI.SLP.SLPUnique)FormView1.FindControl("TextBoxCode")).Text.Trim();
            ParameterList.Add(v_Category);

            DataTable Dt = BCO.QueryLineData(ParameterList);

            Session[SessionIDName] = Dt;

            dt_DetailOLDData = Dt;

            GridView2.DataSource = Dt;
            GridView2.PageIndex = 0;
            GridView2.DataBind();
        }
        catch (Exception ex)
        {
        }
    }//databind_Dtl
コード例 #8
0
ファイル: CGD362.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    }//databind

    /// <summary>
    ///  繫結資料 MST
    /// </summary>
    /// <param name=VirtualDataID></param>
    private void databind_Mst(FormViewMode fvm)
    {
        try
        {
            CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConnectionDB);

            ParameterList.Clear();
            if (Request["ID"] != null)
                ParameterList.Add(Request["ID"].ToString());
            else
                ParameterList.Add("0");

            dt_Result = BCO.QuerySwitch(CGDModel.CGD36_BCO.QueryType.ID, ParameterList);

            if (dt_Result.Rows.Count > 0)
            {
                this.hiddenID.Value = dt_Result.Rows[0]["ID"].ToString();
                FormView1.DataSource = dt_Result;
                FormView1.DataBind();

                if (dt_Result.Rows[0]["ENABLE"].ToString() == "0")
                {
                    ((Button)FormView1.FindControl("EditButton")).Visible = false;
                    ((Button)FormView1.FindControl("DeleteButton")).Visible = false;
                }

            }

            AuthorityControls(this);

            //ToolBarStatus
            switch (fvm)
            {
                case FormViewMode.Edit:
                    ToolBarStatus("edit");
                    TextBox txtcode = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxCode"));
                    TextBox txtname = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxName"));
                    txtname.Visible = false;
                    txtcode.Width = Unit.Parse("18");

                    break;
                case FormViewMode.Insert:
                    ToolBarStatus("insert");
                    TextBox txtcode2 = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxCode"));
                    txtcode2.Width = Unit.Parse("18");
                    break;

                case FormViewMode.ReadOnly:
                    ToolBarStatus("readonly");
                    TextBox txtcode1 = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxCode"));
                    TextBox txtname1 = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxName"));
                    txtname1.Visible = false;
                    txtcode1.Width = Unit.Parse("18");
                    break;
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }

    }//databind_Mst
コード例 #9
0
ファイル: CGD362.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    protected void ButtonExport_Click(object sender, EventArgs e)
    {
        try
        {
            string V_CODE = ((WUI.SLP.SLPUnique)FormView1.FindControl("TextBoxCode")).Text.Trim();
            ErrorMsgLabel.Text = "";

            ParameterList.Clear();
            ParameterList.Add(V_CODE);
            ParameterList.Add(DBNull.Value);
            ParameterList.Add(DBNull.Value);
            ParameterList.Add(DBNull.Value);
            ParameterList.Add(DBNull.Value);
            CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConnectionDB);

            DataTable dtTemp = BCO.GET_EXPORTDATA(ParameterList, false);
            if (dtTemp.Rows.Count == 0)
            {
                ErrorMsgLabel.Text = "查無可匯出資料";
            }
            else
            {
                Export_Excel(dtTemp);
            }
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
コード例 #10
0
ファイル: CGD362.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    }//ButtonNewLine_Click

    /// <summary>
    /// 明細插入鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Btn_Insert_Click(object sender, EventArgs e)
    {
        DataTable Dt = new DataTable();
        DataSet Ds = new DataSet();
        DataTable Ds_detl = new DataTable();

        if (dt_DetailOLDData != null)
        {
            Ds_detl = dt_DetailOLDData;
        }

        try
        {
            if (Ds_detl.Rows.Count == 0)
            {
                //從DB讀取一空table回來                
                CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConnectionDB);
                ParameterList.Clear();
                Dt = BCO.QueryLineSwitch(CGDModel.CGD36_BCO.QueryType.Empty, ParameterList);
            }
            else
            {
                Dt = Ds_detl;//Ds.Tables[0];
            }

            tempID_dtl = 0;

            DataView tempDT = new DataView();
            tempDT.Table = Dt.Copy();
            tempDT.Sort = "ID ASC";
            if (Dt.Rows.Count != 0)
            {
                tempID_dtl = Convert.ToInt32(tempDT[Dt.Rows.Count - 1]["ID"].ToString());
            }

            //ID和PID暫自訂, 真正寫入CO時會重取
            //LineItem畫面元件內容             
            string v_Scode = this.TextBoxScode_Uniq.Text.Trim();
            string v_Explain = this.TextBoxExplain_Fvm.Text.Trim();
            int v_ID = tempID_dtl + 1;

            //檢查SCODE 是否已存在Dt
            DataRow[] ins = Dt.Select(string.Format("SCODE='{0}'", v_Scode));
            if (ins.Length <= 0) //1:已存在Dt 0:不存在Dt
            {
                DataRow dRow = Dt.NewRow();

                dRow["ID"] = v_ID;
                dRow["PID"] = "0";//編輯時不使用 儲存時另外給
                dRow["CREATEDATE"] = DateTime.Now;
                dRow["UPDATEDATE"] = DateTime.Now;
                dRow["CREATEUID"] = Session["UID"];
                dRow["UPDATEUID"] = Session["UID"];
                dRow["ENABLE"] = "1";
                dRow["CATEGORY"] = "0"; //編輯時不使用 儲存時另外給
                dRow["SCODE"] = v_Scode;
                dRow["EXPLAIN"] = v_Explain;
                dRow["FIX_COLUMN"] = "0";

                Dt.Rows.Add(dRow);
            }
            else
            {
                ErrorMsgLabel.Text = "明細代碼重覆!";
                return;
            }

            this.TextBoxScode_Uniq.Text = "";
            this.TextBoxExplain_Fvm.Text = "";
            this.PanelDetail.Visible = false;

            dt_DetailOLDData = Dt;

            BindTempTable_Dtl();

            this.ButtonNewLine.Visible = true;

            Dtl_Status = "readonly";
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;
        }
        finally { }
    }
コード例 #11
0
ファイル: CGD362.aspx.cs プロジェクト: ChiangHanLung/PIC_VDS
    //Update GridView2
    protected void Update_Dtl(System.Data.Common.DbTransaction DBT, DateTime processtime)
    {
        try
        {

            CGDModel.CGD36_BCO BCO = new CGDModel.CGD36_BCO(ConnectionDB);
            string strCode = ((WUI.SLP.SLPUnique)FormView1.FindControl("TextBoxCode")).Text.Trim();
            string strID = ((TextBox)FormView1.FindControl("TextBoxID")).Text.Trim();
            DataTable dtData = dt_DetailOLDData;
            ParameterList.Clear();
            ParameterList.Add(strCode);
            ParameterList.Add(DateTime.Now);
            ParameterList.Add(Session["UID"].ToString());
            BCO.DelCodeFileDTLByCode(ParameterList, DBT);

            for (int i = 0; i < dtData.Rows.Count; i++)
            {


                ParameterList.Clear();
                ParameterList.Add(strID); //CODE_MAIN的ID欄位
                ParameterList.Add(dtData.Rows[i]["CREATEDATE"]);
                ParameterList.Add(dtData.Rows[i]["CREATEUID"]);
                ParameterList.Add(processtime);
                ParameterList.Add(Session["UID"].ToString());
                ParameterList.Add(strCode);//CODE_MAIN的CODE欄位
                ParameterList.Add(dtData.Rows[i]["SCODE"]);
                ParameterList.Add(dtData.Rows[i]["EXPLAIN"]);
                ParameterList.Add(dtData.Rows[i]["FIX_COLUMN"]);

                BCO.CreateCodeFileDTL(ParameterList, DBT);

            }

        }

        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;//error訊息丟出顯示
        }
    }