コード例 #1
0
ファイル: RunDown.aspx.cs プロジェクト: jdiin37/ptchHMC
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName.Equals("cmdEdit"))
                {
                    string strUrl = ResolveUrl(string.Format("~/RunDownAddEdit.aspx?id={0}", e.CommandArgument.ToString()));
                    Response.Redirect(strUrl);
                }
                if (e.CommandName.Equals("cmdDel"))
                {
                    conn = new MyConnection();
                    string     strsql = "select * from [HMC_PkgRundown] where Rundown_Id=@Rundown_Id ";
                    SqlCommand cmd    = new SqlCommand(strsql);
                    cmd.Parameters.Add("@Rundown_Id", SqlDbType.Int).Value = e.CommandArgument.ToString();
                    dt = conn.GetData(cmd);

                    if (dt.Rows.Count > 0)
                    {
                        PublicLib.showAlert("此流程已被設定在套餐內,無法刪除");
                    }
                    else
                    {
                        deleteData(e.CommandArgument.ToString());
                        querySql();
                    }
                }
            }
            catch (Exception ex)
            {
                PublicLib.handleError("", this.GetType().Name, ex.Message);
            }
        }
コード例 #2
0
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.Cells[2].Text == "1")
                {
                    e.Row.Cells[2].Text = "套餐";

                    LinkButton btnson  = (LinkButton)e.Row.FindControl("btnView");
                    LinkButton btnedit = (LinkButton)e.Row.FindControl("btnEdit");

                    btnson.Visible  = false;
                    btnedit.Visible = false;

                    //套餐資訊
                    conn = new MyConnection();
                    string     strcmd = "select * from [HMC_PkgM] Where Id = " + e.Row.Cells[1].Text;
                    SqlCommand cmd    = new SqlCommand(strcmd);
                    DataTable  dt     = conn.GetData(cmd);
                    if (dt.Rows.Count > 0)
                    {
                        e.Row.Cells[0].Text = dt.Rows[0].Field <string>("Name");
                        e.Row.Cells[1].Text = dt.Rows[0].Field <string>("PkgCode");
                    }
                }
                else if (e.Row.Cells[2].Text == "0")
                {
                    e.Row.Cells[2].Text = "類別";
                }
            }
        }
コード例 #3
0
ファイル: RunDown.aspx.cs プロジェクト: jdiin37/ptchHMC
        protected void querySql()
        {
            try
            {
                string strParam = String.Empty;
                if (!txtSearch.Text.Equals(""))
                {
                    strParam += " and NAME Like '%' + @Param + '%'";
                }

                string strSql;
                strSql = "Select * From [HMC_Rundown] Where Rec_Status = 'A'" + strParam + " Order By ID";

                SqlCommand cmd = new SqlCommand(strSql);
                if (!txtSearch.Text.Equals(""))
                {
                    cmd.Parameters.Add("@Param", SqlDbType.NVarChar).Value = txtSearch.Text;
                }
                conn = new MyConnection();
                dt   = conn.GetData(cmd);

                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                PublicLib.handleError("", this.GetType().Name, ex.Message);
            }
        }
コード例 #4
0
ファイル: PkgAddEdit.aspx.cs プロジェクト: jdiin37/ptchHMC
        protected void getQuery()
        {
            strQueCmd = Request.QueryString["cmd"];
            strQueID  = Request.QueryString["PkgId"];
            //strQuePID = Request.QueryString["pid"];

            if (strQueID != null && strQueID != "")
            {
                Label1.Text = "編輯";
                conn        = new MyConnection();
                string     strcmd = "select * from [HMC_PkgM] Where ID = " + strQueID;
                SqlCommand cmd    = new SqlCommand(strcmd);
                DataTable  dt     = conn.GetData(cmd);

                if (dt.Rows.Count > 0)
                {
                    strPkgCode  = dt.Rows[0].Field <string>("PkgCode");
                    strPkgName  = dt.Rows[0].Field <string>("Name");
                    intPkgPrice = dt.Rows[0].Field <int>("PkgPrice");
                }
            }
            else
            {
                Label1.Text = "新增";
            }
        }
コード例 #5
0
ファイル: PkgIndexEdit.aspx.cs プロジェクト: jdiin37/ptchHMC
        protected void edit_mode()
        {
            conn = new MyConnection();
            string     strcmd = "select * from [HMC_PkgRelative] Where ID = " + strQueID;
            SqlCommand cmd    = new SqlCommand(strcmd);
            DataTable  dt     = conn.GetData(cmd);

            if (dt.Rows.Count > 0)
            {
                strPkgCode = dt.Rows[0].Field <string>("PkgCode");
                if (dt.Rows[0].Field <Decimal>("Type") == 1)
                {
                    type_list.SelectedValue = "1";
                    pkg_panel.Attributes.Add("style", "visibility:visible");
                    txtPkgCode.Text = strPkgCode;
                }
                else
                {
                    type_list.SelectedValue = "0";
                    pkg_panel.Attributes.Add("style", "visibility:hidden");
                }

                txtName.Text = dt.Rows[0].Field <string>("Name");
            }
            conn.Dispose();
        }
コード例 #6
0
ファイル: PkgIndexEdit.aspx.cs プロジェクト: jdiin37/ptchHMC
        private void BindGrid() //新增/編輯 套餐
        {
            DataTable dt     = new DataTable();
            string    strcmd = "SELECT ItemCode,Memo FROM HMC_PkgD WHERE 1=0";

            if (strPkgCode != null && strPkgCode != "")
            {
                strcmd = "SELECT ItemCode,Memo FROM HMC_PkgD WHERE PkgCode = @Param";
            }

            SqlCommand cmd = new SqlCommand(strcmd);

            if (strPkgCode != null && strPkgCode != "")
            {
                cmd.Parameters.Add("@Param", SqlDbType.NVarChar).Value = strPkgCode;
            }

            conn = new MyConnection();
            dt   = conn.GetData(cmd);

            if (dt.Rows.Count == 0)
            {
                dt.Rows.Add();
            }
            ViewState["Pkg_Detail"] = dt;
            GridView1.DataSource    = dt;
            GridView1.DataBind();
        }
コード例 #7
0
ファイル: PkgAddEdit.aspx.cs プロジェクト: jdiin37/ptchHMC
        private void BindGrid() //新增/編輯 套餐
        {
            DataTable dt     = new DataTable();
            string    strcmd = "SELECT ItemCode FROM HMC_PkgD WHERE 1=0";

            if (strPkgCode != null && strPkgCode != "")
            {
                strcmd = "SELECT ItemCode FROM HMC_PkgD WHERE PkgCode = @Param";
            }

            SqlCommand cmd = new SqlCommand(strcmd);

            if (strPkgCode != null && strPkgCode != "")
            {
                cmd.Parameters.Add("@Param", SqlDbType.NVarChar).Value = strPkgCode;
            }

            conn = new MyConnection();
            dt   = conn.GetData(cmd);
            dt.Columns.Add("ItemName", typeof(string));
            dt.Columns.Add("ItemPrice", typeof(string));
            if (dt.Rows.Count == 0)
            {
                dt.Rows.Add();
            }
            else
            {
                foreach (DataRow row in dt.Rows) //細項名稱
                {
                    string stritemCode = row["ItemCode"].ToString();
                    using (ODBCconn = new MyODBCConnection())
                    {
                        OdbcCommand odbccmd = new OdbcCommand(strodbccmd);
                        odbccmd.Parameters.Add("item_code", OdbcType.VarChar).Value = stritemCode;
                        DataTable odbcdt = ODBCconn.GetData(odbccmd);

                        if (odbcdt.Rows.Count > 0)
                        {
                            row["ItemName"]  = odbcdt.Rows[0].Field <string>("f_desc");;
                            row["ItemPrice"] = odbcdt.Rows[0].Field <decimal>("amt_ex");
                        }
                        else
                        {
                            string strmsg = string.Format("代碼{0},資料庫中無此代碼", stritemCode);
                            PublicLib.showAlert(strmsg);
                        }
                        odbccmd.Cancel();
                        ODBCconn.Dispose();
                    }
                }
            }
            ViewState["Pkg_Detail"] = dt;
            GridView1.DataSource    = dt;
            GridView1.DataBind();
        }
コード例 #8
0
        protected void querySql()
        {
            try
            {
                string strParam = String.Empty;
                if (!txtSearch.Text.Equals(""))
                {
                    strParam += " And NAME Like '%' + @Param + '%'";

                    string     strsql_pkgm = "select id from [HMC_PkgM] where Name Like '%' + @Param + '%'";
                    SqlCommand cmd_pkgm    = new SqlCommand(strsql_pkgm);
                    cmd_pkgm.Parameters.Add("@Param", SqlDbType.NVarChar).Value = txtSearch.Text;
                    conn = new MyConnection();
                    dt   = conn.GetData(cmd_pkgm);

                    if (dt.Rows.Count > 0)
                    {
                        string strid = string.Empty;
                        foreach (DataRow row in dt.Rows)
                        {
                            strid += row.Field <int>("ID") + ",";
                        }
                        strid    = strid.Substring(0, strid.Length - 1);
                        strParam = " And (NAME Like '%' + @Param + '%' or Pkg_Id in (" + strid + "))";
                    }
                }

                string strSql;

                if (strPID != null && strPID != "")
                {
                    strSql = "Select * From [HMC_Relative] Where Parent_Id =" + strPID + strParam + " Order By Type,ID";
                }
                else
                {
                    strSql = "Select * From [HMC_Relative] Where Parent_Id is null " + strParam + " Order By Type,ID";
                }
                SqlCommand cmd = new SqlCommand(strSql);
                if (!txtSearch.Text.Equals(""))
                {
                    cmd.Parameters.Add("@Param", SqlDbType.NVarChar).Value = txtSearch.Text;
                }
                conn = new MyConnection();
                dt   = conn.GetData(cmd);

                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                PublicLib.handleError("", this.GetType().Name, ex.Message);
            }
        }
コード例 #9
0
        protected void BindGrid()
        {
            try
            {
                string     strSql = "Select RunDown_ID,Seq_No From [HMC_PkgRunDown] Where Pkg_Id = '" + strQuePkgId + "' order by seq_no";
                SqlCommand cmd    = new SqlCommand(strSql);
                conn = new MyConnection();
                DataTable dt = conn.GetData(cmd);

                dt.Columns.Add("Name", typeof(string));

                if (dt.Rows.Count == 0)
                {
                    dt.Rows.Add();
                }
                else
                {
                    foreach (DataRow row in dt.Rows) //細項名稱
                    {
                        string strRunDounID = row["RunDown_ID"].ToString();
                        using (conn = new MyConnection())
                        {
                            string     strSql1 = "Select Name From [HMC_RunDown] Where Id = @Id";
                            SqlCommand cmd1    = new SqlCommand(strSql1);
                            cmd1.Parameters.Add("Id", SqlDbType.Int).Value = int.Parse(strRunDounID);
                            DataTable dt1 = conn.GetData(cmd1);

                            if (dt1.Rows.Count > 0)
                            {
                                row["Name"] = dt1.Rows[0].Field <string>("Name");
                            }
                            else
                            {
                                string strmsg = string.Format("代碼{0},資料庫中無此流程", strRunDounID);
                                PublicLib.showAlert(strmsg);
                            }
                            cmd1.Cancel();
                            conn.Dispose();
                        }
                    }
                }

                ViewState["Pkg_Rundown"] = dt;
                GridView1.DataSource     = dt;
                GridView1.DataBind();
            }
            catch (Exception ex)
            {
                PublicLib.handleError("", this.GetType().Name, ex.Message);
            }
        }
コード例 #10
0
        private Boolean have_child(string ID)
        {
            Boolean bl_rtnflag = false;

            conn = new MyConnection();
            string     strcmd = "select * from [HMC_Relative] Where Parent_Id = " + ID;
            SqlCommand cmd    = new SqlCommand(strcmd);
            DataTable  dt     = conn.GetData(cmd);

            if (dt.Rows.Count > 0)
            {
                bl_rtnflag = true;
            }
            return(bl_rtnflag);
        }
コード例 #11
0
        protected void get_PID()
        {
            strQuePID = Request.QueryString["pid"];
            if (strQuePID != null && strQuePID != "")
            {
                conn = new MyConnection();
                string     strsql = "select * from [HMC_Relative] where Id=@Id";
                SqlCommand cmd    = new SqlCommand(strsql);
                cmd.Parameters.Add("@Id", SqlDbType.Int).Value = strQuePID;
                DataTable dt = conn.GetData(cmd);

                if (dt.Rows.Count > 0)
                {
                    Label1.Text = dt.Rows[0].Field <string>("Name");
                }
            }
        }
コード例 #12
0
        protected void set_path() //定位父子關係
        {
            Panel1.Controls.Clear();
            Panel1.Controls.Add(create_hyperlink("總覽", "~/PkgRelative.aspx"));

            if (strPID != null && strPID != "")
            {
                List <string> list_path = new List <string>();
                string        strpid    = strPID;
                conn = new MyConnection();
                string     strcmd = "select * from [HMC_Relative] Where Id = " + strpid;
                SqlCommand cmd    = new SqlCommand(strcmd);
                DataTable  dt     = conn.GetData(cmd);

                if (dt.Rows.Count > 0)
                {
                    string strurl  = "~/PkgRelative.aspx?PID=";
                    string strname = dt.Rows[0].Field <string>("Name");
                    int?   intpid  = dt.Rows[0].Field <int?>("Parent_Id");
                    list_path.Insert(0, strname + "," + strurl + strpid);
                    while (intpid != null && intpid > 0)//找爸爸的爸爸 and so on
                    {
                        conn   = new MyConnection();
                        strcmd = "select * from [HMC_Relative] Where Id = " + intpid;
                        cmd    = new SqlCommand(strcmd);
                        dt     = conn.GetData(cmd);
                        if (dt.Rows.Count > 0)
                        {
                            strname = dt.Rows[0].Field <string>("Name");
                            list_path.Insert(0, strname + "," + strurl + intpid);
                            intpid = dt.Rows[0].Field <int?>("Parent_Id");
                        }
                    }
                }

                foreach (string listitem in list_path)
                {
                    Panel1.Controls.Add(create_label(">"));
                    Panel1.Controls.Add(create_hyperlink(listitem.Split(',')[0].Trim(), listitem.Split(',')[1].Trim()));
                }
            }
            else
            {
                btnAdd_Pkg.Visible = false;
            }
        }
コード例 #13
0
        protected void getQuery()
        {
            strQuePkgId = Request.QueryString["PkgId"];

            if (strQuePkgId != null && strQuePkgId != "")
            {
                conn = new MyConnection();
                string     strcmd = "select * from [HMC_PkgM] Where Id = '" + strQuePkgId + "'";
                SqlCommand cmd    = new SqlCommand(strcmd);
                DataTable  dt     = conn.GetData(cmd);

                if (dt.Rows.Count > 0)
                {
                    Label1.Text = dt.Rows[0].Field <string>("Name");
                }
            }
        }
コード例 #14
0
ファイル: PkgAddEdit.aspx.cs プロジェクト: jdiin37/ptchHMC
        public static string CheckPkgCode(string CODE)
        {
            MyConnection conn;
            DataTable    dt;
            string       strrtn = "";
            string       strSql;

            strSql = "Select * From [HMC_PkgM] Where Rec_Status = 'A' and PkgCode = '" + CODE + "'";

            SqlCommand cmd = new SqlCommand(strSql);

            conn = new MyConnection();
            dt   = conn.GetData(cmd);
            if (dt.Rows.Count > 0)
            {
                strrtn = "此代碼已經存在";
            }

            return(strrtn);
        }
コード例 #15
0
        protected void getQuery()
        {
            strQueID = Request.QueryString["ID"];

            if (strQueID != null && strQueID != "")
            {
                Label1.Text = "編輯";
                conn        = new MyConnection();
                string     strcmd = "select * from [HMC_Rundown] Where ID = " + strQueID;
                SqlCommand cmd    = new SqlCommand(strcmd);
                DataTable  dt     = conn.GetData(cmd);

                if (dt.Rows.Count > 0)
                {
                    strName = dt.Rows[0].Field <string>("Name");
                }
            }
            else
            {
                Label1.Text = "新增";
            }
        }
コード例 #16
0
ファイル: PkgRunDown.aspx.cs プロジェクト: jdiin37/ptchHMC
        protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //e.Row.Cells[0].Visible = false;
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                Label         lb1       = (Label)e.Row.FindControl("Label1");
                Label         lbPid     = (Label)e.Row.FindControl("LabelPid");
                List <string> list_path = new List <string>();
                string        strSql    = "Select Name,ParentId From [HMC_PkgRelative] Where Id = " + lbPid.Text;
                SqlCommand    cmd       = new SqlCommand(strSql);
                conn = new MyConnection();
                DataTable dt = conn.GetData(cmd);

                if (dt.Rows.Count > 0)
                {
                    list_path.Insert(0, dt.Rows[0].Field <string>("Name"));
                    int?intpid = dt.Rows[0].Field <int?>("ParentId");
                    while (intpid != null && intpid > 0)
                    {
                        strSql = "Select Name,ParentId From [HMC_PkgRelative] Where Id = " + intpid;
                        cmd    = new SqlCommand(strSql);
                        conn   = new MyConnection();
                        dt     = conn.GetData(cmd);
                        if (dt.Rows.Count > 0)
                        {
                            list_path.Insert(0, dt.Rows[0].Field <string>("Name"));
                            intpid = dt.Rows[0].Field <int?>("ParentId");
                        }
                    }
                }

                foreach (string listitem in list_path)
                {
                    lb1.Text += listitem + ">";
                }
            }
        }