Пример #1
0
        public static ProductBrandList GetEditProductBrandData(string id, int index)
        {
            //  Set active row
            HttpContext.Current.Session["ROW_ID"] = id;
            HttpContext.Current.Session["ROW"]    = index;

            var productBrandData   = new ProductBrandList();
            var dsDataProductBrand = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    List <SqlParameter> arrParm = new List <SqlParameter>
                    {
                        new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                        {
                            Value = ""
                        },
                        new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = Convert.ToInt32(id)
                        }
                    };
                    conn.Open();
                    dsDataProductBrand = SqlHelper.ExecuteDataset(conn, "sp_product_brand_list", arrParm.ToArray());
                    conn.Close();
                }

                if (dsDataProductBrand.Tables.Count > 0)
                {
                    var row = dsDataProductBrand.Tables[0].Rows[0];
                    productBrandData.id             = Convert.IsDBNull(row["id"]) ? 0 : Convert.ToInt32(row["id"]);
                    productBrandData.brand_code     = Convert.IsDBNull(row["brand_code"]) ? null : Convert.ToString(row["brand_code"]);
                    productBrandData.brand_name_eng = Convert.IsDBNull(row["brand_name_tha"]) ? null : Convert.ToString(row["brand_name_tha"]);
                    productBrandData.brand_name_tha = Convert.IsDBNull(row["brand_name_eng"]) ? null : Convert.ToString(row["brand_name_eng"]);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(productBrandData);
        }
        public static EmployeeDepartmentList GetEditDepartmentData(string id, int index)
        {
            //  Set active row
            HttpContext.Current.Session["ROW_ID"] = id;
            HttpContext.Current.Session["ROW"]    = index;

            var employeeDepartmentData   = new EmployeeDepartmentList();
            var dsDataEmployeeDepartment = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    List <SqlParameter> arrParm = new List <SqlParameter>
                    {
                        new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = Convert.ToInt32(id)
                        },
                        new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                        {
                            Value = ""
                        }
                    };
                    conn.Open();
                    dsDataEmployeeDepartment = SqlHelper.ExecuteDataset(conn, "sp_employee_department_list", arrParm.ToArray());
                    conn.Close();
                }

                if (dsDataEmployeeDepartment.Tables.Count > 0)
                {
                    var row = dsDataEmployeeDepartment.Tables[0].Rows[0];
                    employeeDepartmentData.id       = Convert.IsDBNull(row["id"]) ? 0 : Convert.ToInt32(row["id"]);
                    employeeDepartmentData.name_tha = Convert.IsDBNull(row["name_tha"]) ? null : Convert.ToString(row["name_tha"]);
                    employeeDepartmentData.name_eng = Convert.IsDBNull(row["name_eng"]) ? null : Convert.ToString(row["name_eng"]);
                    employeeDepartmentData.type     = Convert.IsDBNull(row["service_type"]) ? "" : Convert.ToString(row["service_type"]);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(employeeDepartmentData);
        }
Пример #3
0
        public static string ReadNotification(int id)
        {
            using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
            {
                using (SqlCommand cmd = new SqlCommand("sp_notification_update_read", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@id", SqlDbType.Int).Value         = id;
                    cmd.Parameters.Add("@updated_by", SqlDbType.Int).Value = Convert.ToInt32(ConstantClass.SESSION_USER_ID);


                    conn.Open();
                    cmd.ExecuteNonQuery();;
                    conn.Close();
                }
            }
            return("READ");
        }
Пример #4
0
        protected void BindGrid(bool isForceRefreshData = false)
        {
            try
            {
                if (!Page.IsPostBack || isForceRefreshData)
                {
                    using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                    {
                        //Create array of Parameters
                        List <SqlParameter> arrParm = new List <SqlParameter>
                        {
                            new SqlParameter("@user_id", SqlDbType.Int)
                            {
                                Value = ConstantClass.SESSION_USER_ID
                            },
                            new SqlParameter("@id", SqlDbType.Int)
                            {
                                Value = 0
                            },
                            new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                            {
                                Value = ""
                            }
                        };

                        conn.Open();
                        dsResult = SqlHelper.ExecuteDataset(conn, "sp_sale_order_header_list", arrParm.ToArray());
                        conn.Close();
                        Session["SESSION_SALE_ORDER_LIST"] = dsResult;
                    }
                }

                //Bind data into GridView
                gridView.DataSource       = dsResult;
                gridView.FilterExpression = FilterBag.GetExpression(false);
                gridView.DataBind();
            }
            catch (Exception ex)
            {
                string strErrorMsg = SPlanetUtil.LogErrorCollect(ex);
                ScriptManager.RegisterStartupScript(this, GetType(), "myalert", "alert('" + strErrorMsg + "');", true);
            }
        }
Пример #5
0
        protected void gridView_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            var dsResult = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    using (SqlCommand cmd = new SqlCommand("sp_config_list", conn))
                    {
                        //Create array of Parameters
                        List <SqlParameter> arrParm = new List <SqlParameter>
                        {
                            new SqlParameter("@config_document", SqlDbType.Char, 2)
                            {
                                Value = ""
                            },
                            new SqlParameter("@config_type", SqlDbType.Char, 1)
                            {
                                Value = ""
                            },
                            new SqlParameter("@id", SqlDbType.Int)
                            {
                                Value = 0
                            },
                        };
                        conn.Open();
                        dsResult = SqlHelper.ExecuteDataset(conn, "sp_config_list_doc", arrParm.ToArray());
                        conn.Close();
                        ViewState["dsResult"] = dsResult;
                    }

                    //Bind data into GridView
                    gridView.DataSource       = dsResult;
                    gridView.FilterExpression = FilterBag.GetExpression(false);
                    gridView.DataBind();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    //Create array of Parameters
                    List <SqlParameter> arrParm = new List <SqlParameter>
                    {
                        new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                        {
                            Value = ""
                        },
                        new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = 0
                        },
                    };
                    conn.Open();
                    var dsResult = SqlHelper.ExecuteDataset(conn, "sp_customer_list", arrParm.ToArray());

                    conn.Close();
                    cbbCustomer.DataSource = dsResult;
                    cbbCustomer.TextField  = "code_name";
                    cbbCustomer.ValueField = "id";
                    cbbCustomer.DataBind();

                    cbbProject.Items.Insert(0, new ListEditItem("ทั้งหมด", ""));
                    cbbProject.SelectedIndex = 0;
                }
                // Get Permission and if no permission, will redirect to another page.
                if (!Permission.GetPermission())
                {
                    Response.Redirect(ConstantClass.CONSTANT_NO_PERMISSION_PAGE);
                }
            }
            else
            {
                gridAnnualServiceList.DataSource       = (from t in annualServiceListData select t).ToList();
                gridAnnualServiceList.FilterExpression = FilterBag.GetExpression(false);
                gridAnnualServiceList.DataBind();
            }
        }
Пример #7
0
        protected void BindGrid(bool isForceRefreshData = false)
        {
            try
            {
                if (!Page.IsPostBack || isForceRefreshData)
                {
                    using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                    {
                        //Create array of Parameters
                        List <SqlParameter> arrParm = new List <SqlParameter>
                        {
                            new SqlParameter("@id", SqlDbType.Int)
                            {
                                Value = 0
                            },
                            new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                            {
                                Value = ""
                            },
                            new SqlParameter("@service_type", SqlDbType.VarChar, 100)
                            {
                                Value = ConstantClass.SESSION_DEPARTMENT_SERVICE_TYPE
                            },
                        };
                        conn.Open();
                        dsResult = SqlHelper.ExecuteDataset(conn, "sp_delivery_order_header_list", arrParm.ToArray());
                        conn.Close();
                        Session["SESSION_DELIVERY_ORDER_LIST"] = dsResult;
                    }
                }

                //Bind data into GridView
                gridViewDeliveryOrder.DataSource       = dsResult;
                gridViewDeliveryOrder.FilterExpression = FilterBag.GetExpression(false);
                gridViewDeliveryOrder.DataBind();
            }
            catch (Exception ex)
            {
                string strErrorMsg = SPlanetUtil.LogErrorCollect(ex);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "AlertMessage", "alertMessage('" + ex.Message + "','E')", true);
            }
        }
        public static string UpdateSupplierBranch(SupplierBranchList[] supplierBranchUpdateData)
        {
            var row = (from t in supplierBranchUpdateData select t).FirstOrDefault();

            if (row != null)
            {
                try
                {
                    using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                    {
                        using (SqlCommand cmd = new SqlCommand("sp_supplier_branch_edit", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(row.id);
                            cmd.Parameters.Add("@supplier_code", SqlDbType.VarChar, 20).Value    = row.supplier_code;
                            cmd.Parameters.Add("@branch_no", SqlDbType.VarChar, 5).Value         = row.branch_no;
                            cmd.Parameters.Add("@branch_name_tha", SqlDbType.VarChar, 100).Value = row.branch_name_tha;
                            cmd.Parameters.Add("@branch_name_eng", SqlDbType.VarChar, 100).Value = row.branch_name_eng;
                            cmd.Parameters.Add("@address_tha", SqlDbType.VarChar, 200).Value     = row.address_tha;
                            cmd.Parameters.Add("@address_eng", SqlDbType.VarChar, 200).Value     = row.address_eng;
                            cmd.Parameters.Add("@geo_id", SqlDbType.Int).Value          = row.geo_id;
                            cmd.Parameters.Add("@province_id", SqlDbType.Int).Value     = row.province_id;
                            cmd.Parameters.Add("@amphur_id", SqlDbType.Int).Value       = row.amphur_id;
                            cmd.Parameters.Add("@district_id", SqlDbType.Int).Value     = row.district_id;
                            cmd.Parameters.Add("@zipcode", SqlDbType.VarChar, 10).Value = row.zipcode;
                            cmd.Parameters.Add("@is_enable", SqlDbType.Int).Value       = 1;
                            cmd.Parameters.Add("@is_delete", SqlDbType.Int).Value       = 0;
                            cmd.Parameters.Add("@updated_by", SqlDbType.Int).Value      = Convert.ToInt32(ConstantClass.SESSION_USER_ID);

                            conn.Open();
                            cmd.ExecuteNonQuery();
                            conn.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return("success");
        }
Пример #9
0
 public static void BindASPxComboBox(ref ASPxComboBox control_name, string storeprocedure_name)
 {
     using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
     {
         if (storeprocedure_name.Equals(DataListUtil.DropdownStoreProcedureName.Issue_Sale_Order) ||
             storeprocedure_name.Equals(DataListUtil.DropdownStoreProcedureName.Delivery_Note_Issue) ||
             storeprocedure_name.Equals(DataListUtil.DropdownStoreProcedureName.Delivery_Order_Issue_Stock)
             )
         {
             List <SqlParameter> arrParm = new List <SqlParameter>
             {
                 new SqlParameter("@lang_id", SqlDbType.VarChar, 3)
                 {
                     Value = "tha"
                 },
                 new SqlParameter("@service_type", SqlDbType.VarChar, 100)
                 {
                     Value = ConstantClass.SESSION_DEPARTMENT_SERVICE_TYPE
                 },
             };
             conn.Open();
             using (DataSet dsResult = SqlHelper.ExecuteDataset(SPlanetUtil.GetConnectionString(), storeprocedure_name, arrParm.ToArray()))
             {
                 control_name.DataSource = dsResult;
                 control_name.TextField  = "data_text";
                 control_name.ValueField = "data_value";
                 control_name.DataBind();
             }
         }
         else
         {
             conn.Open();
             using (DataSet dsResult = SqlHelper.ExecuteDataset(SPlanetUtil.GetConnectionString(), CommandType.StoredProcedure, storeprocedure_name))
             {
                 control_name.DataSource = dsResult;
                 control_name.TextField  = "data_text";
                 control_name.ValueField = "data_value";
                 control_name.DataBind();
             }
         }
     }
 }
Пример #10
0
        public static string DeleteSaleOrder(string id)
        {
            string data = "success";

            using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
            {
                conn.Open();
                using (SqlTransaction tran = conn.BeginTransaction())
                {
                    try
                    {
                        using (SqlCommand cmd = new SqlCommand("sp_sale_order_delete", conn, tran))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add("@id", SqlDbType.Int).Value         = Convert.ToInt32(id);
                            cmd.Parameters.Add("@updated_by", SqlDbType.Int).Value = Convert.ToInt32(ConstantClass.SESSION_USER_ID);


                            cmd.ExecuteNonQuery();
                        }
                    }
                    catch (Exception ex)
                    {
                        tran.Rollback();
                        tran.Dispose();
                        conn.Close();
                        //throw ex;
                        return(ex.Message.ToString());
                    }
                    finally
                    {
                        if (!conn.State.Equals(ConnectionState.Closed))
                        {
                            tran.Commit();
                            tran.Dispose();
                            conn.Close();
                        }
                    }
                }
            }
            return(data);
        }
Пример #11
0
        protected void gridView_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            var dsResult = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    //Create array of Parameters
                    List <SqlParameter> arrParm = new List <SqlParameter>
                    {
                        new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = 0
                        },
                        new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                        {
                            Value = e.Parameters.ToString()
                        },
                        new SqlParameter("@service_type", SqlDbType.VarChar, 100)
                        {
                            Value = ConstantClass.SESSION_DEPARTMENT_SERVICE_TYPE
                        },
                    };
                    conn.Open();
                    dsResult = SqlHelper.ExecuteDataset(conn, "sp_issue_header_list", arrParm.ToArray());
                    conn.Close();
                    Session["SESSION_ISSUE_LIST"] = dsResult;
                }

                //Bind data into GridView
                gridView.DataSource       = dsResult;
                gridView.FilterExpression = FilterBag.GetExpression(false);
                gridView.DataBind();
            }
            catch (Exception ex)
            {
                string strErrorMsg = SPlanetUtil.LogErrorCollect(ex);
                ScriptManager.RegisterStartupScript(this, GetType(), "myalert", "alert('" + strErrorMsg + "');", true);
            }
        }
Пример #12
0
        protected void gridView_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            var dsResult = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    //Create array of Parameters
                    List <SqlParameter> arrParm = new List <SqlParameter>
                    {
                        new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = 0
                        },
                        new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                        {
                            Value = e.Parameters.ToString()
                        },
                        new SqlParameter("@return_type", SqlDbType.VarChar, 200)
                        {
                            Value = strReturnType == "" ? "" :strReturnType
                        }
                    };
                    conn.Open();
                    dsResult = SqlHelper.ExecuteDataset(conn, "sp_return_header_list", arrParm.ToArray());
                    conn.Close();
                    Session["SESSION_RETURN_LIST"] = dsResult;
                }

                //Bind data into GridView
                gridView.DataSource       = dsResult;//(from t in dsResult.Tables[0].AsEnumerable() where t.Field<string>("return_type") == strReturnType select t).ToList(); ;
                gridView.FilterExpression = FilterBag.GetExpression(false);
                gridView.DataBind();
            }
            catch (Exception ex)
            {
                string strErrorMsg = SPlanetUtil.LogErrorCollect(ex);
                ScriptManager.RegisterStartupScript(this, GetType(), "myalert", "alert('" + strErrorMsg + "');", true);
            }
        }
Пример #13
0
        public static ReturnDetail GetReturnData(string id, string hdReturnType)
        {
            var data = new ReturnDetail();

            using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
            {
                //Create array of Parameters
                List <SqlParameter> arrParm = new List <SqlParameter>
                {
                    new SqlParameter("@id", SqlDbType.Int)
                    {
                        Value = Convert.ToInt32(id)
                    },
                    new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                    {
                        Value = ""
                    },
                    new SqlParameter("@return_type", SqlDbType.VarChar, 200)
                    {
                        Value = hdReturnType == "" ? "" :hdReturnType
                    }
                };
                conn.Open();
                var dsReturnData = SqlHelper.ExecuteDataset(conn, "sp_return_header_list", arrParm.ToArray());
                conn.Close();

                if (dsReturnData.Tables.Count > 0)
                {
                    if (dsReturnData.Tables[0].Rows.Count > 0)
                    {
                        var row = (from t in dsReturnData.Tables[0].AsEnumerable() select t).FirstOrDefault();
                        if (row != null)
                        {
                            data.return_no = Convert.IsDBNull(row["return_no"]) ? string.Empty : Convert.ToString(row["return_no"]);
                        }
                    }
                }
            }

            return(data);
        }
Пример #14
0
        public static DeliveryOrderHeaderList GetDeliveryNoteData(string id)
        {
            var data = new DeliveryOrderHeaderList();

            using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
            {
                //Create array of Parameters
                List <SqlParameter> arrParm = new List <SqlParameter>
                {
                    new SqlParameter("@id", SqlDbType.Int)
                    {
                        Value = Convert.ToInt32(id)
                    },
                    new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                    {
                        Value = ""
                    },
                    new SqlParameter("@service_type", SqlDbType.VarChar, 100)
                    {
                        Value = ConstantClass.SESSION_DEPARTMENT_SERVICE_TYPE
                    },
                };
                conn.Open();
                var dsDeliveryNoteData = SqlHelper.ExecuteDataset(conn, "sp_delivery_order_header_list", arrParm.ToArray());
                conn.Close();

                if (dsDeliveryNoteData.Tables.Count > 0)
                {
                    if (dsDeliveryNoteData.Tables[0].Rows.Count > 0)
                    {
                        var row = (from t in dsDeliveryNoteData.Tables[0].AsEnumerable() select t).FirstOrDefault();
                        if (row != null)
                        {
                            data.delivery_order_no = Convert.IsDBNull(row["delivery_order_no"]) ? string.Empty : Convert.ToString(row["delivery_order_no"]);
                        }
                    }
                }
            }

            return(data);
        }
Пример #15
0
        public static ShelfDetail ShelfEdit(string id, int index)
        {
            //  Set active row
            HttpContext.Current.Session["ROW_ID"] = id;
            HttpContext.Current.Session["ROW"]    = index;

            var dataShelf = new ShelfDetail();
            var dsShelf   = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    List <SqlParameter> arrParm = new List <SqlParameter>
                    {
                        new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = Convert.ToInt32(id)
                        },
                        new SqlParameter("@search_name", SqlDbType.VarChar, 200)
                        {
                            Value = ""
                        },
                    };
                    conn.Open();
                    dsShelf = SqlHelper.ExecuteDataset(conn, "sp_shelf_list", arrParm.ToArray());
                    conn.Close();
                }
                if (dsShelf.Tables.Count > 0)
                {
                    var row = dsShelf.Tables[0].Rows[0];
                    dataShelf.id         = Convert.IsDBNull(row["id"]) ? 0 : Convert.ToInt32(row["id"]);
                    dataShelf.shelf_name = Convert.IsDBNull(row["shelf_name"]) ? null : Convert.ToString(row["shelf_name"]);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dataShelf);
        }
        public static QuotationHeaderList GetQuotationData(string id)
        {
            var data = new QuotationHeaderList();

            using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
            {
                //Create array of Parameters
                List <SqlParameter> arrParm = new List <SqlParameter>
                {
                    new SqlParameter("@id", SqlDbType.Int)
                    {
                        Value = id
                    },
                };
                conn.Open();
                var dsQuataionData = SqlHelper.ExecuteDataset(conn, "sp_quotation_list_data", arrParm.ToArray());
                conn.Close();

                if (dsQuataionData.Tables.Count > 0)
                {
                    if (dsQuataionData.Tables[0].Rows.Count > 0)
                    {
                        var row = (from t in dsQuataionData.Tables[0].AsEnumerable() select t).FirstOrDefault();
                        if (row != null)
                        {
                            data.id                  = Convert.ToInt32(id);
                            data.quotation_no        = Convert.IsDBNull(row["quotation_no"]) ? string.Empty : Convert.ToString(row["quotation_no"]);
                            data.quotation_status    = Convert.IsDBNull(row["quotation_status"]) ? string.Empty : Convert.ToString(row["quotation_status"]);
                            data.quotation_type      = Convert.IsDBNull(row["quotation_type"]) ? string.Empty : Convert.ToString(row["quotation_type"]);
                            data.is_discount_by_item = Convert.IsDBNull(row["is_discount_by_item"]) ? false : Convert.ToBoolean(row["is_discount_by_item"]);
                            data.discount1_type      = Convert.IsDBNull(row["discount1_type"]) ? string.Empty : Convert.ToString(row["discount1_type"]);
                            data.is_net              = Convert.IsDBNull(row["is_net"]) ? false : Convert.ToBoolean(row["is_net"]);
                            data.discount2_type      = Convert.IsDBNull(row["discount2_type"]) ? string.Empty : Convert.ToString(row["discount2_type"]);
                        }
                    }
                }
            }

            return(data);
        }
        public static string InsertCustomerBranch(CustomerBranchList[] customerBranchAddData)
        {
            var row = (from t in customerBranchAddData select t).FirstOrDefault();

            if (row != null)
            {
                try
                {
                    using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                    {
                        using (SqlCommand cmd = new SqlCommand("sp_customer_branch_add", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add("@branch_no", SqlDbType.VarChar, 10).Value            = Convert.ToString(row.branch_no);
                            cmd.Parameters.Add("@branch_name", SqlDbType.VarChar, 200).Value         = Convert.ToString(row.branch_name);
                            cmd.Parameters.Add("@customer_id", SqlDbType.Int).Value                  = Convert.ToInt32(row.customer_id);
                            cmd.Parameters.Add("@address_bill_tha", SqlDbType.VarChar, 200).Value    = Convert.ToString(row.address_bill_tha);
                            cmd.Parameters.Add("@address_bill_eng", SqlDbType.VarChar, 200).Value    = Convert.ToString(row.address_bill_eng);
                            cmd.Parameters.Add("@address_install_tha", SqlDbType.VarChar, 200).Value = Convert.ToString(row.address_install_tha);
                            cmd.Parameters.Add("@address_install_eng", SqlDbType.VarChar, 200).Value = Convert.ToString(row.address_install_eng);
                            cmd.Parameters.Add("@geo_id", SqlDbType.Int).Value          = Convert.ToInt32(row.geo_id);
                            cmd.Parameters.Add("@province_id", SqlDbType.Int).Value     = Convert.ToInt32(row.province_id);
                            cmd.Parameters.Add("@amphur_id", SqlDbType.Int).Value       = Convert.ToInt32(row.amphur_id);
                            cmd.Parameters.Add("@district_id", SqlDbType.Int).Value     = Convert.ToInt32(row.district_id);
                            cmd.Parameters.Add("@zipcode", SqlDbType.VarChar, 10).Value = Convert.ToString(row.zipcode);
                            cmd.Parameters.Add("@created_by", SqlDbType.Int).Value      = Convert.ToInt32(ConstantClass.SESSION_USER_ID);

                            conn.Open();
                            cmd.ExecuteNonQuery();
                            conn.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return("success");
        }
Пример #18
0
        protected void gridView_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            var dsResult = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    //Create array of Parameters
                    List <SqlParameter> arrParm = new List <SqlParameter>
                    {
                        new SqlParameter("@search_name", SqlDbType.VarChar, 150)
                        {
                            Value = e.Parameters.ToString()
                        },
                        new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = 0
                        }
                    };
                    conn.Open();
                    dsResult = SqlHelper.ExecuteDataset(conn, "sp_supplier_brand_list", arrParm.ToArray());
                    conn.Close();
                    Session["SESSION_SUPPLIER_BRAND_MASTER"] = dsResult;

                    Session["SEARCH"] = e.Parameters.ToString();
                }

                //Bind data into GridView
                gridView.DataSource       = dsResult;
                gridView.FilterExpression = FilterBag.GetExpression(false);
                gridView.DataBind();
            }
            catch (Exception ex)
            {
                string strErrorMsg = SPlanetUtil.LogErrorCollect(ex);
                ScriptManager.RegisterStartupScript(this, GetType(), "myalert", "alert('" + strErrorMsg + "');", true);
            }
        }
Пример #19
0
        protected void cbbSupplier_Callback(object sender, CallbackEventArgsBase e)
        {
            using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
            {
                List <SqlParameter> arrParm = new List <SqlParameter>
                {
                    new SqlParameter("@lang_id", SqlDbType.VarChar, 3)
                    {
                        Value = ""
                    },
                };
                conn.Open();
                var dsResult = SqlHelper.ExecuteDataset(conn, "sp_dropdown_supplier", arrParm.ToArray());
                conn.Close();
                cbbSupplier.DataSource = dsResult;
                cbbSupplier.TextField  = "data_text";
                cbbSupplier.ValueField = "data_value";
                cbbSupplier.DataBind();

                cbbSupplier.Items.Insert(0, new ListEditItem("All Supplier", "0"));
            }
        }
Пример #20
0
        public static ApproveDetail EditApprove(string id)
        {
            var dataApprove = new ApproveDetail();
            var dsApprove   = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    List <SqlParameter> arrParm = new List <SqlParameter>
                    {
                        new SqlParameter("@id", SqlDbType.Int)
                        {
                            Value = Convert.ToInt32(id)
                        }
                    };
                    conn.Open();
                    dsApprove = SqlHelper.ExecuteDataset(conn, "sp_approve_list", arrParm.ToArray());
                    conn.Close();
                }
                if (dsApprove.Tables.Count > 0)
                {
                    var row = dsApprove.Tables[0].Rows[0];
                    dataApprove.id        = Convert.IsDBNull(row["id"]) ? 0 : Convert.ToInt32(row["id"]);
                    dataApprove.name_app1 = Convert.IsDBNull(row["name_app1"]) ? null : Convert.ToString(row["name_app1"]);
                    dataApprove.name_app2 = Convert.IsDBNull(row["name_app2"]) ? null : Convert.ToString(row["name_app2"]);
                    dataApprove.name_app3 = Convert.IsDBNull(row["name_app3"]) ? null : Convert.ToString(row["name_app3"]);

                    dataApprove.approve_id1 = Convert.IsDBNull(row["id_app1"]) ? null : Convert.ToString(row["id_app1"]);
                    dataApprove.approve_id2 = Convert.IsDBNull(row["id_app2"]) ? null : Convert.ToString(row["id_app2"]);
                    dataApprove.approve_id3 = Convert.IsDBNull(row["id_app3"]) ? null : Convert.ToString(row["id_app3"]);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(dataApprove);
        }
Пример #21
0
 public static void DeleteShelf(string id)
 {
     try
     {
         using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
         {
             using (SqlCommand cmd = new SqlCommand("sp_shelf_delete", conn))
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@id", SqlDbType.Int).Value         = Convert.ToInt32(id);
                 cmd.Parameters.Add("@updated_by", SqlDbType.Int).Value = Convert.ToInt32(ConstantClass.SESSION_USER_ID);
                 conn.Open();
                 cmd.ExecuteNonQuery();
                 conn.Close();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Пример #22
0
        public static string ChangeStatus(string refer_id, string refer_name, string refer_type)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    List <SqlParameter> arrParmQU = new List <SqlParameter>
                    {
                        new SqlParameter("@user_id", SqlDbType.Int)
                        {
                            Value = Convert.ToInt32(ConstantClass.SESSION_USER_ID)
                        },
                        new SqlParameter("@refer_id", SqlDbType.Int)
                        {
                            Value = Convert.ToInt32(refer_id)
                        },
                        new SqlParameter("@refer_name", SqlDbType.VarChar, 150)
                        {
                            Value = Convert.ToString(refer_name)
                        },
                        new SqlParameter("@refer_type", SqlDbType.VarChar, 150)
                        {
                            Value = Convert.ToString(refer_type)
                        }
                        // new SqlParameter("@customer_id", SqlDbType.Int) { Value = 0 },
                    };

                    conn.Open();
                    var insertLogApprove = SqlHelper.ExecuteDataset(conn, "sp_approve_log_add", arrParmQU.ToArray());
                    conn.Close();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return("success");
        }
        public static string UpdateIndustryType(CustomerIndustryList[] industryTypeUpdateData)
        {
            var row = (from t in industryTypeUpdateData select t).FirstOrDefault();

            if (row != null)
            {
                try
                {
                    using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                    {
                        using (SqlCommand cmd = new SqlCommand("sp_customer_industry_edit", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(row.id);
                            cmd.Parameters.Add("@name_tha", SqlDbType.VarChar, 200).Value      = row.name_tha;
                            cmd.Parameters.Add("@name_eng", SqlDbType.VarChar, 200).Value      = row.name_eng;
                            cmd.Parameters.Add("@parent_id", SqlDbType.Int).Value              = 0;
                            cmd.Parameters.Add("@begin_char_thai", SqlDbType.VarChar, 2).Value = "ก";
                            cmd.Parameters.Add("@is_enable", SqlDbType.Bit).Value              = true;
                            cmd.Parameters.Add("@is_delete", SqlDbType.Bit).Value              = false;
                            cmd.Parameters.Add("@updated_by", SqlDbType.Int).Value             = Convert.ToInt32(ConstantClass.SESSION_USER_ID);

                            conn.Open();
                            cmd.ExecuteNonQuery();
                            conn.Close();
                        }
                    }

                    //  Set new id
                    HttpContext.Current.Session["ROW_ID"] = Convert.ToString(row.id);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return("success");
        }
        protected void cbbProductModel_Callback(object sender, CallbackEventArgsBase e)
        {
            using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
            {
                List <SqlParameter> arrParm = new List <SqlParameter>
                {
                    new SqlParameter("@cat_cade", SqlDbType.VarChar, 2)
                    {
                        Value = "AC"
                    },
                };
                conn.Open();

                var dsResult = SqlHelper.ExecuteDataset(conn, "sp_dropdown_product_model", arrParm.ToArray());
                conn.Close();
                cbbProductModel.DataSource = dsResult;
                cbbProductModel.TextField  = "product_model";
                cbbProductModel.ValueField = "product_model";
                cbbProductModel.DataBind();

                cbbProductModel.Items.Insert(0, new ListEditItem("All Product Model", "0"));
            }
        }
Пример #25
0
        protected void cbbSecondaryCode_Callback(object sender, CallbackEventArgsBase e)
        {
            using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
            {
                List <SqlParameter> arrParm = new List <SqlParameter>
                {
                    new SqlParameter("@lang_id", SqlDbType.VarChar, 3)
                    {
                        Value = ""
                    },
                };
                conn.Open();
                var storeName = cbbProductType.Value.ToString() == "PP" ? "sp_dropdown_product" : "sp_dropdown_product_spare_part";
                var dsResult  = SqlHelper.ExecuteDataset(conn, storeName, arrParm.ToArray());
                conn.Close();
                cbbSecondaryCode.DataSource = dsResult;
                cbbSecondaryCode.TextField  = "data_text";
                cbbSecondaryCode.ValueField = "data_value";
                cbbSecondaryCode.DataBind();

                cbbSecondaryCode.Items.Insert(0, new ListEditItem("All Secondary Code", "0"));
            }
        }
Пример #26
0
    public static void BindASPxComboBox(ref ASPxComboBox control_name, string storeprocedure_name, List <SqlParameter> arrParm)
    {
        using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
        {
            DataSet dsResult = new DataSet();
            conn.Open();
            dsResult = SqlHelper.ExecuteDataset(conn, storeprocedure_name, arrParm.ToArray());

            control_name.DataSource = dsResult;
            control_name.TextField  = "data_text";
            control_name.ValueField = "data_value";
            control_name.DataBind();

            conn.Close();
        }
        //using (DataSet dsResult = SqlHelper.ExecuteDataset(SPlanetUtil.GetConnectionString(), CommandType.StoredProcedure, storeprocedure_name))
        //{
        //    control_name.DataSource = dsResult;
        //    control_name.TextField = "data_text";
        //    control_name.ValueField = "data_value";
        //    control_name.DataBind();
        //}
    }
        public static string UpdateCustomerGroup(CustomerGroupList[] customerGroupUpdateData)
        {
            var row = (from t in customerGroupUpdateData select t).FirstOrDefault();

            if (row != null)
            {
                try
                {
                    using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                    {
                        using (SqlCommand cmd = new SqlCommand("sp_customer_group_edit", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add("@id", SqlDbType.Int).Value = Convert.ToInt32(row.id);
                            cmd.Parameters.Add("@mac5_code", SqlDbType.VarChar, 20).Value       = row.mac5_code;
                            cmd.Parameters.Add("@group_name_tha", SqlDbType.VarChar, 100).Value = row.group_name_tha;
                            cmd.Parameters.Add("@group_name_eng", SqlDbType.VarChar, 100).Value = row.group_name_eng;
                            cmd.Parameters.Add("@group_remark", SqlDbType.VarChar, 150).Value   = row.group_remark;
                            cmd.Parameters.Add("@is_enable", SqlDbType.Bit).Value  = true;
                            cmd.Parameters.Add("@updated_by", SqlDbType.Int).Value = Convert.ToInt32(ConstantClass.SESSION_USER_ID);

                            conn.Open();
                            cmd.ExecuteNonQuery();
                            conn.Close();
                        }
                    }

                    //  Set new id
                    HttpContext.Current.Session["ROW_ID"] = Convert.ToString(row.id);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return("success");
        }
Пример #28
0
        public static ZipcodeList GetZipcode(string districtID)
        {
            var zipcodeData = new ZipcodeList();
            var dsZipcode   = new DataSet();

            try
            {
                using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                {
                    List <SqlParameter> arrParm = new List <SqlParameter>
                    {
                        new SqlParameter("@district_id", SqlDbType.Int)
                        {
                            Value = Convert.ToInt32(districtID)
                        }
                    };
                    conn.Open();
                    dsZipcode = SqlHelper.ExecuteDataset(conn, "sp_dropdrown_tb_thailand_5_zipcode", arrParm.ToArray());
                    conn.Close();
                }

                if (dsZipcode.Tables.Count > 0)
                {
                    var row = dsZipcode.Tables[0].Rows[0];

                    zipcodeData.amphur_id   = Convert.IsDBNull(row["amphur_id"]) ? 0 : Convert.ToInt32(row["amphur_id"]);
                    zipcodeData.district_id = Convert.IsDBNull(row["district_id"]) ? 0 : Convert.ToInt32(row["district_id"]);
                    zipcodeData.zipcode     = Convert.IsDBNull(row["zipcode"]) ? null : Convert.ToString(row["zipcode"]);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(zipcodeData);
        }
        public static int ConfirmAddParent(ProductCategoryDetail[] cateProductLevel1)
        {
            int newID     = DataListUtil.emptyEntryID;//idเปล่า
            var parent_id = 0;
            var row       = (from t in cateProductLevel1 select t).FirstOrDefault();

            if (row != null)
            {
                try
                {
                    using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                    {
                        using (SqlCommand cmd = new SqlCommand("sp_product_category_add", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add("@cat_name_tha", SqlDbType.VarChar, 100).Value = row.cat_name_tha;
                            cmd.Parameters.Add("@cat_name_eng", SqlDbType.VarChar, 100).Value = row.cat_name_eng;
                            cmd.Parameters.Add("@cat_type", SqlDbType.VarChar, 2).Value       = row.cat_type;
                            cmd.Parameters.Add("@parent_id", SqlDbType.Int).Value             = row.parent_id;
                            cmd.Parameters.Add("@level_no", SqlDbType.Int).Value   = row.level_no + 1;
                            cmd.Parameters.Add("@created_by", SqlDbType.Int).Value = Convert.ToInt32(ConstantClass.SESSION_USER_ID);

                            conn.Open();
                            newID = Convert.ToInt32(cmd.ExecuteScalar());
                            conn.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
                parent_id = row.parent_id;
            }

            return(parent_id);
        }
Пример #30
0
        public static void NotificationConfirmAdd(NotificationDetail[] dataNotic)
        {
            int newID = DataListUtil.emptyEntryID; //idเปล่า
            var row   = (from t in dataNotic select t).FirstOrDefault();

            if (row != null)
            {
                try {
                    using (SqlConnection conn = new SqlConnection(SPlanetUtil.GetConnectionString()))
                    {
                        using (SqlCommand cmd = new SqlCommand("sp_notification_add", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add("@subject", SqlDbType.VarChar, 100).Value          = row.subject;
                            cmd.Parameters.Add("@description", SqlDbType.VarChar, 100).Value      = row.description;
                            cmd.Parameters.Add("@customer_id", SqlDbType.Int).Value               = Convert.ToInt32(row.customer_id);
                            cmd.Parameters.Add("@notice_type", SqlDbType.VarChar, 2).Value        = row.notice_type;
                            cmd.Parameters.Add("@notice_date", SqlDbType.DateTime).Value          = row.notice_date;
                            cmd.Parameters.Add("@is_enable", SqlDbType.Bit).Value                 = Convert.ToInt32(row.is_enable);
                            cmd.Parameters.Add("@is_delete", SqlDbType.Bit).Value                 = 0;
                            cmd.Parameters.Add("@created_by", SqlDbType.Int).Value                = Convert.ToInt32(ConstantClass.SESSION_USER_ID);
                            cmd.Parameters.Add("@company_name_tha", SqlDbType.VarChar, 300).Value = row.company_name_tha;


                            conn.Open();
                            newID = Convert.ToInt32(cmd.ExecuteScalar());
                            conn.Close();
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }