Beispiel #1
0
        protected Boolean check_itemExist()
        {
            Boolean bl_rtnflag = false;

            using (ODBCconn = new MyODBCConnection())
            {
                OdbcCommand cmd = new OdbcCommand(strodbccmd);
                cmd.Parameters.Add("item_code", OdbcType.VarChar).Value = txtItemCode.Text;
                DataTable dt = ODBCconn.GetData(cmd);
                if (dt.Rows.Count > 0) //--資料庫裡面找不到資料
                {
                    txtItemName.Text  = dt.Rows[0].Field <string>("f_desc");
                    txtItemPrice.Text = dt.Rows[0].Field <decimal>("amt_ex").ToString();
                    bl_rtnflag        = true;
                }
                else
                {
                    PublicLib.showAlert("資料庫無此細項代碼喔");
                    txtItemCode.Text  = "";
                    txtItemName.Text  = "";
                    txtItemPrice.Text = "";
                    bl_rtnflag        = false;
                }
                cmd.Cancel();
                ODBCconn.Dispose();
            }
            return(bl_rtnflag);
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
        protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                if (e.CommandName.Equals("cmdView"))
                {
                    string strUrl = ResolveUrl(string.Format("~/PkgRelative.aspx?PID={0}", e.CommandArgument.ToString()));
                    Response.Redirect(strUrl, false);
                }

                if (e.CommandName.Equals("cmdEdit"))
                {
                    string strUrl = ResolveUrl(string.Format("~/ClassAddEdit.aspx?cmd={0}&pid={1}&ID={2}", "edit", strPID, e.CommandArgument));
                    Response.Redirect(strUrl);
                }

                if (e.CommandName.Equals("cmdDel"))
                {
                    if (have_child(e.CommandArgument.ToString()))
                    {
                        PublicLib.showAlert("請先刪除子項目內的資料");
                    }
                    else
                    {
                        delete_Relative(e.CommandArgument.ToString());
                        querySql();
                    }
                }
            }
            catch (Exception ex)
            {
                PublicLib.handleError("", this.GetType().Name, ex.Message);
            }
        }
Beispiel #4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                var list_seq = new List <string>();

                foreach (GridViewRow row in GridView1.Rows)
                {
                    TextBox txtseq = (TextBox)row.FindControl("txtSeqNo");
                    if (list_seq.Contains(txtseq.Text))
                    {
                        PublicLib.showAlert("歐歐 排序有重複喔");
                        return;
                    }
                    list_seq.Add(txtseq.Text);
                }

                conn = new MyConnection();
                if (1 == 1)
                {
                    Delete_PkgRunDown();
                    Insert_PkgRunDown();
                    conn.Muti_Insert(list_sqlcmd);
                }
            }
            catch (Exception ex)
            {
                PublicLib.handleError("", this.GetType().Name, ex.Message);
            }

            Response.Redirect("~/PkgIndex.aspx");
        }
Beispiel #5
0
        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();
        }
Beispiel #6
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);
            }
        }
Beispiel #7
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (ViewState["Pkg_Rundown"] != null)
            {
                DataTable dt   = (DataTable)ViewState["Pkg_Rundown"];
                DataRow   drow = null;

                string strRundown_ID   = ddlRunDown.SelectedValue;
                string strRundown_Name = ddlRunDown.SelectedItem.Text;

                if (dt.Rows.Count > 0)
                {
                    var list_RundownID = new List <string>();

                    foreach (DataRow dr in dt.Rows)
                    {
                        list_RundownID.Add(dr["RunDown_ID"].ToString());

                        if (list_RundownID.Contains(strRundown_ID))
                        {
                            PublicLib.showAlert("歐歐 此排程已經存在");
                            return;
                        }
                        list_RundownID.Add(dr["RunDown_ID"].ToString());
                    }

                    drow = dt.NewRow();
                    drow["RunDown_ID"] = int.Parse(strRundown_ID);
                    drow["Name"]       = strRundown_Name;
                }

                if (dt.Rows[0][0].ToString() == "")
                {
                    dt.Rows[0].Delete();
                    dt.AcceptChanges();
                }
                //add created Rows into dataTable
                dt.Rows.Add(drow);
                //Save Data table into view state after creating each row
                ViewState["Pkg_Rundown"] = dt;
                //Bind Gridview with latest Row
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
        }