Пример #1
0
    public string BusDocumentMetaName(string Code)
    {
        string Name = "";
        string ConnectionDBStr = ((DatabaseSettings)ConfigurationManager.GetSection("dataConfiguration")).DefaultDatabase;
        MaintainBusDocumentMeta BCO = new MaintainBusDocumentMeta(ConnectionDBStr);

        ArrayList ParameterList = new ArrayList();
        ParameterList.Clear();        
        ParameterList.Add(Code);

        if (Code != "")
        {
            DataTable Dt = BCO.QueryForSLP(ParameterList);

            if (Dt.Rows.Count > 0)
            {
                Name = Dt.Rows[0]["Name"].ToString().Trim();
            }
            else
            {
                Name = "無資料";
            }
        }

        return Name;
    }
Пример #2
0
    /// <summary>
    /// 於檢視模式,按下刪除鈕

    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DeleteButton_Click(object sender, EventArgs e)
    {
        int DeleteRecord = 0;
        try
        {
            #region 取得畫面元件的值

            DateTime processtime = DateTime.Now;

            #endregion

            #region 取得刪除前舊值


            #region 使用XML轉回DataSet

            DataSet Ds = new DataSet();         
            DataTable Dt = dt_Result;
            #endregion

            if (Dt.Rows.Count == 0)
            {
                throw new Exception("抓取不到舊值,更新失敗!");
            }

            #endregion

            #region 加入更新條件

            ParameterList.Clear();
            //舊值


            ParameterList.Add(Dt.Rows[0]["ID"]);
            ParameterList.Add(Dt.Rows[0]["CODE"]);
            ParameterList.Add(Dt.Rows[0]["NAME"]);
            ParameterList.Add(DateTime.Parse((Dt.Rows[0]["CREATEDATE"]).ToString()));
            ParameterList.Add(Dt.Rows[0]["CREATEUID"]);
            ParameterList.Add(DateTime.Parse((Dt.Rows[0]["UPDATEDATE"]).ToString()));
            ParameterList.Add(Dt.Rows[0]["UPDATEUID"]);
            ParameterList.Add(Dt.Rows[0]["ENABLE"]);
            ParameterList.Add(Dt.Rows[0]["MODEL"]);
            ParameterList.Add(Dt.Rows[0]["DESCRIPTION"]);
            ParameterList.Add(Dt.Rows[0]["IOTYPE"]);
            ParameterList.Add(Dt.Rows[0]["WEBURL"]);
            ParameterList.Add(Dt.Rows[0]["DOCIDSERIALNEXT"]);
            ParameterList.Add(Dt.Rows[0]["DOCCODESERIALNEXT"]);
            ParameterList.Add(Dt.Rows[0]["PRECODE"]);
            ParameterList.Add(DateTime.Parse((Dt.Rows[0]["APLDATE"]).ToString()).ToString("yyyyMMdd"));
            ParameterList.Add(Dt.Rows[0]["SERIALFORMAT"]);
            //需要更新值

            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());
            #endregion

            SYSModel.MaintainBusDocumentMeta BCO = new SYSModel.MaintainBusDocumentMeta(ConnectionDB);

            DeleteRecord = BCO.DeleteBusDocumentMetaReturn(ParameterList, null);

            if (DeleteRecord == 0)
            {
                throw new Exception("刪除失敗!");
            }
            else
            {
                Response.Write("<script>alert('刪除完成');location.replace('SYS091.aspx?Code=SYS09');</script>");
            }

        }
        catch (Exception ex)
        {
           ErrorMsgLabel.Text = ex.Message;
        }
    }
Пример #3
0
    }//end EditCancelButton_Click

    /// <summary>
    ///  編輯模式,按下更新確認鈕
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void EditCommitButton_Click(object sender, EventArgs e)
    {        
        try
        {
            ErrorMsgLabel.Text = "";

            int UpdateRecord = 0;

            #region 取得畫面元件的值

            string v_Name = ((TextBox)FormView1.FindControl("TextBoxName")).Text.Trim();
            DateTime processtime = DateTime.Now;
            string v_Model = ((TextBox)FormView1.FindControl("TextBoxModel")).Text.Trim();
            string v_Description = ((TextBox)FormView1.FindControl("TextBoxDescription")).Text.Trim();
            string v_Weburl = ((TextBox)FormView1.FindControl("TextBoxWebURL")).Text.Trim();
            string v_Doctid = ((TextBox)FormView1.FindControl("TextBoxDocIDSerialNext")).Text.Trim();
            string v_DocCode = ((TextBox)FormView1.FindControl("TextBoxDocCodeSerialNext")).Text.Trim();
            string v_IOtype = ((WUI.SLP.ENVIOType)FormView1.FindControl("SLP_IOType")).Text.Trim();
            string v_PreCode = ((TextBox)FormView1.FindControl("TextBoxPreCode")).Text.Trim();            
            string v_AplDate = "";
            if (((WUI.SLP.SLPDate)FormView1.FindControl("SLP_AplDate")).Text == "")
            {
                v_AplDate = "";
            }
            else
            {     
                DateTime newapldate;
                newapldate = DateTime.Parse(((WUI.SLP.SLPDate)FormView1.FindControl("SLP_AplDate")).Text.Trim());
                DateTime sysdate;
                sysdate = DateTime.Now;


                if (newapldate.ToString("yyyyMMdd") != sysdate.ToString("yyyyMMdd"))
                {
                    if (newapldate.CompareTo(sysdate) < 0)
                    {

                        ShowErrorMessage("業務日期需大於等於系統日期");
                        return;
                    }
                    else
                    {
                        v_AplDate = ((WUI.SLP.SLPDate)FormView1.FindControl("SLP_AplDate")).Text.Trim().Replace("/", "");
                    }
                }
                else
                {
                    v_AplDate = ((WUI.SLP.SLPDate)FormView1.FindControl("SLP_AplDate")).Text.Trim().Replace("/", "");
                }
            }
            string v_SerialFormat = ((TextBox)FormView1.FindControl("TextBoxSerialFormat")).Text.Trim();
            string v_Enable = "1";// ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_Enable")).Text.Trim();

            #endregion

            #region 取得更新前舊值

            #region 使用XML轉回DataSet
            DataSet Ds = new DataSet();           
            DataTable Dt = dt_Result;
            #endregion

            if (Dt.Rows.Count == 0)          
            {
                throw new Exception("抓取不到舊值,更新失敗!");
            }

            #endregion

            #region 加入更新條件

            ParameterList.Clear();         

            //舊值
            ParameterList.Add(Dt.Rows[0]["ID"]);
            ParameterList.Add(Dt.Rows[0]["CODE"]);
            ParameterList.Add(Dt.Rows[0]["NAME"]);
            ParameterList.Add(DateTime.Parse((Dt.Rows[0]["CREATEDATE"]).ToString()));
            ParameterList.Add(Dt.Rows[0]["CREATEUID"]);
            ParameterList.Add(DateTime.Parse((Dt.Rows[0]["UPDATEDATE"]).ToString()));
            ParameterList.Add(Dt.Rows[0]["UPDATEUID"]);
            ParameterList.Add(Dt.Rows[0]["ENABLE"]);
            ParameterList.Add(Dt.Rows[0]["MODEL"]);
            ParameterList.Add(Dt.Rows[0]["DESCRIPTION"]);
            ParameterList.Add(Dt.Rows[0]["IOTYPE"]);
            ParameterList.Add(Dt.Rows[0]["WEBURL"]);
            ParameterList.Add(Dt.Rows[0]["DOCIDSERIALNEXT"]);
            ParameterList.Add(Dt.Rows[0]["DOCCODESERIALNEXT"]);
            ParameterList.Add(Dt.Rows[0]["PRECODE"]);
            if (Dt.Rows[0]["APLDATE"].ToString() != "")
            {
              ParameterList.Add(DateTime.Parse((Dt.Rows[0]["APLDATE"]).ToString()).ToString("yyyyMMdd"));
            }
            else
            {
              ParameterList.Add(Dt.Rows[0]["APLDATE"]);
            }
            ParameterList.Add(Dt.Rows[0]["SERIALFORMAT"]);

            //需要更新值
            ParameterList.Add(v_Name);
            ParameterList.Add(processtime);
            ParameterList.Add(Session["UID"].ToString());
            ParameterList.Add(v_Model);
            ParameterList.Add(v_Description);

            if (v_IOtype != "")
            { ParameterList.Add(int.Parse(v_IOtype)); }
            else
            { ParameterList.Add(0); }        
            ParameterList.Add(v_Weburl);
            if (v_Doctid != "")
            { ParameterList.Add(Decimal.Parse(v_Doctid)); }
            else
            { ParameterList.Add(1); }

            if (v_DocCode != "")
            { ParameterList.Add(Decimal.Parse(v_DocCode)); 
            }
            else
            { ParameterList.Add(1); }     

            ParameterList.Add(v_PreCode);
            ParameterList.Add(v_AplDate);//YYMMDD
            ParameterList.Add(v_SerialFormat);
            ParameterList.Add(v_Enable);

            #endregion

            SYSModel.MaintainBusDocumentMeta BCO = new SYSModel.MaintainBusDocumentMeta(ConnectionDB);

            UpdateRecord = BCO.UpdateBusDocumentMetaReturn(ParameterList, null);

            if (UpdateRecord == 0)
            {
                throw new Exception("更新0筆資料!");
            }
            else
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "SYS092", "<script>alert('更改完成');</script>");
                ChangeFormMode(FormViewMode.ReadOnly);               
            } 
        }
        catch (Exception ex)
        {
            ErrorMsgLabel.Text = ex.Message;            
        }
    }
Пример #4
0
    }//end InsertCancelButton_Click


    /// <summary>
    /// 由新增模式,確認新增
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void InsertButton_Click(object sender, EventArgs e)
    {
        int AddRecord = 0;
        try
        {
            ErrorMsgLabel.Text = "";

            #region 取得畫面元件的值

            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_Model = ((TextBox)FormView1.FindControl("TextBoxModel")).Text.Trim();
            string v_Description = ((TextBox)FormView1.FindControl("TextBoxDescription")).Text.Trim();
            string v_Weburl = ((TextBox)FormView1.FindControl("TextBoxWebURL")).Text.Trim();
            string v_Doctid = ((TextBox)FormView1.FindControl("TextBoxDocIDSerialNext")).Text.Trim();
            string v_DocCode = ((TextBox)FormView1.FindControl("TextBoxDocCodeSerialNext")).Text.Trim();
            string v_IOtype = ((WUI.SLP.ENVIOType)this.FormView1.FindControl("SLP_IOType")).Text.Trim();
            string v_PreCode = ((TextBox)FormView1.FindControl("TextBoxPreCode")).Text.Trim();
            string v_AplDate = DateTime.Now.ToString("yyyyMMdd").ToString();          
            string v_SerialFormat = ((TextBox)FormView1.FindControl("TextBoxSerialFormat")).Text.Trim();
            string v_Is_Need_Date = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_NeedDate")).Text.Trim();
            string v_Is_Need_Check = ((WUI.SLP.SLP_Boolean)FormView1.FindControl("SLP_NeedCheck")).Text.Trim();

            ParameterList.Clear();
            SYSModel.MaintainProgram Uniq = new SYSModel.MaintainProgram(ConnectionDB);
            ParameterList.Add(v_Code);
            ParameterList.Add("SYS_BusDocumentMeta");
            ParameterList.Add("CODE");
            ParameterList.Add("");
            DataTable Dup = Uniq.QuerySwitch(SYSModel.MaintainProgram.QueryType.Duplicate,
                                         ParameterList
                                         );
            if (Dup.Rows.Count > 0)
            {
                if (Dup.Rows[0]["ENABLE"].ToString() == "1")
                {
                    throw new Exception("資料重覆!");
                }
            }

            #endregion

            #region 加入輸入條件

            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_Model);
            ParameterList.Add(v_Description);

            if (v_IOtype != "")
            { ParameterList.Add(int.Parse(v_IOtype));}
            else
            { ParameterList.Add(0);}

            ParameterList.Add(v_Weburl);
            if (v_Doctid != "")
            { ParameterList.Add(Decimal.Parse(v_Doctid)); }
            else
            { ParameterList.Add(0);}

            if (v_DocCode != "")
            { ParameterList.Add(int.Parse(v_DocCode)); }
            else
            { ParameterList.Add(1); }

            ParameterList.Add(v_PreCode);
            ParameterList.Add(v_AplDate);//ParameterList.Add(v_AplDate.Replace("/", ""));
            ParameterList.Add(v_SerialFormat);

            if (v_Is_Need_Date != "")
            { ParameterList.Add(int.Parse(v_Is_Need_Date)); }
            else
            { ParameterList.Add(1);}

            if (v_Is_Need_Check != "")
            { ParameterList.Add(int.Parse(v_Is_Need_Check)); }
            else
            { ParameterList.Add(0); }

            #endregion

            SYSModel.MaintainBusDocumentMeta BCO = new SYSModel.MaintainBusDocumentMeta(ConnectionDB);
            AddRecord = BCO.CreateBusDocumentMeta(ParameterList, null);

            if (AddRecord == 0)
            {
                throw new Exception("新增0筆資料!");
            }
            else
            {
                Response.Write("<script>alert('新增完成');location.replace('SYS092.aspx?mode=readonly&ID=" + AddRecord + "');</script>");
            }
        }
        catch (Exception ex)
        {
           ErrorMsgLabel.Text = ex.Message;
        }

    }
Пример #5
0
    /// <summary>
    /// 取得所有Master資料以巡覽
    /// </summary>
    private void GetAllMasterRecordsForBrowse()
    {
        #region
        SYSModel.MaintainBusDocumentMeta BCO = new SYSModel.MaintainBusDocumentMeta(ConnectionDB);
        DataTable dtTemp = BCO.QueryBusDocumentMetaByALL();
        DataView dvForBrowse = dtTemp.DefaultView;
        dtForBrowse = dvForBrowse.ToTable();

        #endregion
    }
Пример #6
0
    private void Loaddata(string NewCode)
    {
        SYSModel.MaintainBusDocumentMeta BCO = new SYSModel.MaintainBusDocumentMeta(ConnectionDB);
        ParameterList.Clear();
        ParameterList.Add(NewCode);
        DataTable Dt = BCO.QueryBusDocumentMetaByID(ParameterList);

        if (Dt != null)
        {
            if (Dt.Rows.Count == 0)
            {
                ArrayList AL = (ArrayList)Session["SYS09_SortKey" + Request.QueryString["SYS092_PageTimeStamp"]];

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

                throw new Exception("此筆資料已被其他使用者刪除,請點選上一筆/下一筆鈕或回查詢頁重新查詢!");
            }
        }
    }
Пример #7
0
    /// <summary>
    /// 繫結資料
    /// </summary>
    /// <param name=VirtualDataID></param>
    private void databind(FormViewMode fvm)
    {
        try
        {
            SYSModel.MaintainBusDocumentMeta BCO = new SYSModel.MaintainBusDocumentMeta(ConnectionDB);

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

            dt_Result = BCO.QuerySwitch(SYSModel.MaintainBusDocumentMeta.QueryType.ID,
                                           ParameterList
                                           );
           
            if (dt_Result.Rows.Count > 0)
            {
                this.hiddenID.Value = dt_Result.Rows[0]["ID"].ToString();
                FormView1.DataSource = dt_Result;
                FormView1.DataBind();
            }

            AuthorityControls(this);

            //ToolBarStatus
            switch (fvm)
            {
                case FormViewMode.Edit:

                    //修改All換為空值
                    DropDownList D1 = ((DropDownList)this.FormView1.FindControl("SLP_IOType").FindControl("D1"));
                    D1.Items.RemoveAt(0);
                    TextBox edit_txtname = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxName"));
                    edit_txtname.Visible = false;

                    ToolBarStatus("edit");
                    break;
                case FormViewMode.Insert:                            
                    ((TextBox)this.FormView1.FindControl("SLP_AplDate").FindControl("TextBoxCode")).Text = DateTime.Now.ToString("yyyy/MM/dd");

                    ToolBarStatus("insert");
                    break;
                case FormViewMode.ReadOnly:

                    //修改All換為空值
                    DropDownList D3 = ((DropDownList)this.FormView1.FindControl("SLP_IOType").FindControl("D1"));
                    D3.Items[0].Text = "";
                    TextBox txtname = ((TextBox)this.FormView1.FindControl("TextBoxCode").FindControl("TextBoxName"));
                    txtname.Visible = false;

                    ToolBarStatus("readonly");
                    break;
            }
        }
        catch (Exception ex)
        {
           ErrorMsgLabel.Text = ex.Message;
        }

    }//databind
Пример #8
0
    /// <summary>
    /// 查詢資料庫取得資料
    /// </summary> 
    private void databind()
    {
        //抓取本頁初次登記的時間
        string SessionIDName = "SYS091_" + PageTimeStamp.Value;

        SYSModel.MaintainBusDocumentMeta BCO = new SYSModel.MaintainBusDocumentMeta(ConntionDB);

        ParameterList.Clear();
        ParameterList.Add(TextBoxCode.Text.Trim());
        ParameterList.Add(TextBoxName.Text.Trim());
        ParameterList.Add(TextBoxCreateDate.StartDate.Trim());
        ParameterList.Add(TextBoxCreateDate.EndDate.Trim());
        ParameterList.Add(TextBoxCreateUID.Text.Trim());
        ParameterList.Add(TextBoxUpdateDate.StartDate.Trim());
        ParameterList.Add(TextBoxUpdateDate.EndDate.Trim());
        ParameterList.Add(TextBoxUpdateUID.Text.Trim());
        ParameterList.Add(TextBoxModel.Text.Trim());
        ParameterList.Add(TextBoxDescription.Text.Trim());
        ParameterList.Add(TextBoxWebURL.Text.Trim());
        ParameterList.Add(TextBoxDocIDSerialNext.Text.Trim());
        ParameterList.Add("1");//SLP_Enable.Text.Trim());
        ParameterList.Add(((DropDownList)SLP_IOType.FindControl("D1")).SelectedValue);
        ParameterList.Add(TextBoxPreCode.Text.Trim());
        ParameterList.Add(TextBoxSerialFormat.Text.Trim());
        ParameterList.Add(SLP_AplDate.Text.Trim().Replace("/",""));
        ParameterList.Add(TextBoxDocCodeSerialNext.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["SYS09_SortKey" + this.PageTimeStamp.Value] = arl_Key;

        #endregion

        if (Dt.Rows.Count == 0)
        { this.ErrorMsgLabel.Text = "查無資料"; }
    }
 public BusDocumentMeta()
 {
     co_main = new BCO.MaintainBusDocumentMeta(ConntionDB);
 }
        }//Initiziatoin_Component

        private void dataget()
        {
            ParameterList.Clear();
            SYSModel.MaintainBusDocumentMeta BCO = new SYSModel.MaintainBusDocumentMeta(ConntionDB);
            ParameterList.Add(_Code);

            if (_Code != "")
            {
                DataTable Dt = BCO.QueryForSLP(ParameterList);
                //DataTable Dt = BCO.QuerySwitch(SYSModel.MaintainBusDocumentMeta.QueryType.CODE,
                //                          ParameterList
                //                          );
                if (Dt.Rows.Count > 0)
                {
                    _Name = Dt.Rows[0]["Name"].ToString().Trim();
                }
                else
                {
                    _Name = "無資料";
                }
            }
            HiddenField1.Value = _Name;
            TextBoxName.Text = _Name;

        }//dataget