Beispiel #1
0
    private void SetUpDrowDownList()
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        try
        {
            //ddl_ProductGroup
            List <dbo_ProductClass> ProductGroup = dbo_ProductDataClass.Search(string.Empty, string.Empty, string.Empty, null, string.Empty).GroupBy(f => f.Product_group_ID).Select(grb => grb.First()).ToList();
            dbo_ProductClass        b            = new dbo_ProductClass();
            dbo_ProductClass        c1           = new dbo_ProductClass();
            b.Product_group_ID  = "เลือกทั้งหมด";
            c1.Product_group_ID = "อื่นๆ";
            ProductGroup.Insert(0, b);
            ProductGroup.Insert(ProductGroup.Count, c1);
            ddl_ProductGroup.DataSource = ProductGroup;
            ddl_ProductGroup.DataBind();

            ddl_Size.Items.Insert(0, "เลือกทั้งหมด");
            ddl_Size.SelectedIndex = 0;

            CountStockDate_From.Text = DateTime.Now.ToShortDateString();
            CountStockDate_To.Text   = DateTime.Now.ToShortDateString();
        }
        catch (Exception ex)
        {
            logger.Error(ex);
        }
    }
Beispiel #2
0
    private void InsertRecord()
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        dbo_ProductClass clsdbo_Product = new dbo_ProductClass();

        SetData(clsdbo_Product);


        bool   success = false;
        string User_ID = HttpContext.Current.Request.Cookies["User_ID"].Value;

        success = dbo_ProductDataClass.Add(clsdbo_Product, User_ID);

        dbo_ProductListClass clsdbo_ProductList = new dbo_ProductListClass();


        List <dbo_PriceGroupClass> price_group    = dbo_PriceGroupDataClass.Search(string.Empty, "0");
        dbo_PriceGroupClass        price_group_id = price_group.FirstOrDefault(f => f.StandardPrice == true);

        clsdbo_ProductList.Price_Group_ID  = price_group_id.Price_Group_ID;
        clsdbo_ProductList.Product_List_ID = GenerateID.Product_List_ID();
        var date = new DateTime(9456, 12, 31);

        clsdbo_ProductList.Agent_Price            = clsdbo_Product.Agent_Price;
        clsdbo_ProductList.Product_Effective_Date = DateTime.Now;
        clsdbo_ProductList.Start_Effective_Date   = DateTime.Now;
        clsdbo_ProductList.End_Effective_Date     = date;
        clsdbo_ProductList.Product_ID             = clsdbo_Product.Product_ID;
        clsdbo_ProductList.Product_Name           = clsdbo_Product.Product_Name;
        clsdbo_ProductList.Point = clsdbo_Product.Point;
        clsdbo_ProductList.Vat   = clsdbo_Product.Vat;
        //clsdbo_ProductList.CP_Meiji_Price = clsdbo_Product.CP_Meiji_Price;

        dbo_ProductListDataClass.Add(clsdbo_ProductList, User_ID);

        price_group    = dbo_PriceGroupDataClass.Search(string.Empty, "1");
        price_group_id = price_group.FirstOrDefault(f => f.StandardPrice == true);


        if (price_group_id != null)
        {
            clsdbo_ProductList.Price_Group_ID  = price_group_id.Price_Group_ID;
            clsdbo_ProductList.SP_Price        = clsdbo_Product.SP_Price;
            clsdbo_ProductList.CP_Meiji_Price  = clsdbo_Product.CP_Meiji_Price;
            clsdbo_ProductList.Agent_Price     = null;
            clsdbo_ProductList.Product_List_ID = GenerateID.Product_List_ID();

            dbo_ProductListDataClass.Add(clsdbo_ProductList, User_ID);
        }

        if (success)
        {
            Show("บันทึกสำเร็จ");
        }
        else
        {
            Show("error");
        }
    }
Beispiel #3
0
    private void UpdateRecord()
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        dbo_ProductClass clsdbo_Product = new dbo_ProductClass();

        clsdbo_Product = dbo_ProductDataClass.Select_Record(txtProduct_ID.Text);

        SetData(clsdbo_Product);

        bool   success = false;
        string User_ID = HttpContext.Current.Request.Cookies["User_ID"].Value;

        success = dbo_ProductDataClass.Update(clsdbo_Product, User_ID);


        List <dbo_ProductListClass> product_list       = dbo_ProductListDataClass.Search(string.Empty, string.Empty, txtProduct_ID.Text);
        dbo_ProductListClass        product_list_id    = product_list.FirstOrDefault(f => f.StandardPrice == true && f.Price_Group_Type == "0");//Agent
        dbo_ProductListClass        clsdbo_ProductList = new dbo_ProductListClass();

        if (product_list_id != null)
        {
            clsdbo_ProductList = dbo_ProductListDataClass.Select_Record(product_list_id.Product_List_ID);
            clsdbo_ProductList.Product_Name = clsdbo_Product.Product_Name;
            clsdbo_ProductList.Vat          = clsdbo_Product.Vat;
            clsdbo_ProductList.Agent_Price  = clsdbo_Product.Agent_Price;
            success = dbo_ProductListDataClass.Update(clsdbo_ProductList, User_ID);
        }

        dbo_ProductListClass product_list_id1 = product_list.FirstOrDefault(f => f.StandardPrice == true && f.Price_Group_Type == "1");//SP

        //dbo_ProductListClass clsdbo_ProductList = new dbo_ProductListClass();
        if (product_list_id1 != null)
        {
            clsdbo_ProductList = dbo_ProductListDataClass.Select_Record(product_list_id1.Product_List_ID);
            clsdbo_ProductList.Product_Name   = clsdbo_Product.Product_Name;
            clsdbo_ProductList.Vat            = clsdbo_Product.Vat;
            clsdbo_ProductList.SP_Price       = clsdbo_Product.SP_Price;
            clsdbo_ProductList.CP_Meiji_Price = clsdbo_Product.CP_Meiji_Price;
            clsdbo_ProductList.Point          = clsdbo_Product.Point;
            success = dbo_ProductListDataClass.Update(clsdbo_ProductList, User_ID);
        }

        if (success)
        {
            Show("บันทึกสำเร็จ");
        }
        //else
        //{
        //    Show("error");
        //}
    }
Beispiel #4
0
    protected void txtProduct_ID_TextChanged(object sender, EventArgs e)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        try
        {
            dbo_ProductClass product = dbo_ProductDataClass.Select_Record(txtProduct_ID.Text);
            if (product != null)
            {
                System.Threading.Thread.Sleep(500);
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
                Show("รหัสสินค้าไม่สามารถซ้ำได้");
                txtProduct_ID.Text = string.Empty;
            }

            System.Threading.Thread.Sleep(500);
            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "SAMWAIT", "myApp.hidePleaseWait();", true);
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
Beispiel #5
0
    private void SetUpDrowDownList()
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        try
        {
            string        User_ID    = Request.Cookies["User_ID"].Value;
            dbo_UserClass user_class = dbo_UserDataClass.Select_Record(User_ID);


            if (user_class.User_Group_ID == "CP Meiji")
            {
                //ddlSearchRegion
                String   strString = user_class.Region;
                String[] myArr     = strString.Split(',');
                Dictionary <string, string> region = dbo_ItemDataClass.GetDropDown_Report("07");

                ddlSearchRegion.DataSource = region.Where(f => myArr.Contains(f.Value));
                ddlSearchRegion.DataBind();
                ddlSearchRegion.Items.Insert(0, "เลือกทั้งหมด");

                if (ddlSearchRegion.SelectedIndex == 0)
                {
                    String[] region_tmp = region.Where(f => myArr.Contains(f.Value)).Select(f => f.Value).ToArray();
                    //ddlAgentName
                    List <dbo_AgentClass> agent    = dbo_AgentDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Active", string.Empty);
                    List <dbo_AgentClass> cv_code1 = new List <dbo_AgentClass>(agent.Where(f => f.DM_ID == User_ID || f.GM_ID == User_ID.Trim() || f.SD_ID == User_ID.Trim() || f.SM_ID == User_ID.Trim() || f.APV_ID == User_ID.Trim()).Select(f => f));

                    if (cv_code1.Count > 0)
                    {
                        ddlAgentName.DataSource = cv_code1;
                        ddlAgentName.DataBind();
                        ddlAgentName.Items.Insert(0, "เลือกทั้งหมด");
                    }
                    else
                    {
                        ddlAgentName.DataSource = agent.Where(f => region_tmp.Contains(f.Location_Region)).OrderBy(f => f.CV_AgentName);
                        ddlAgentName.DataBind();
                        ddlAgentName.Items.Insert(0, "เลือกทั้งหมด");
                    }
                }
            }
            else
            {
                //ddlSearchRegion
                List <dbo_AgentClass> agent = dbo_AgentDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Active", string.Empty);
                String[] rg = agent.Where(f => f.CV_Code == user_class.CV_CODE.Trim()).Select(f => f.Location_Region).ToArray();

                Dictionary <string, string> region = dbo_ItemDataClass.GetDropDown_Report("07");
                ddlSearchRegion.DataSource = region.Where(f => rg.Contains(f.Value));
                ddlSearchRegion.DataBind();
                ddlSearchRegion.Enabled = false;
                //ddlAgentName
                //List<dbo_AgentClass> agent = dbo_AgentDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Active", string.Empty);
                ddlAgentName.DataSource = agent.Where(f => f.CV_Code == user_class.CV_CODE.Trim());
                ddlAgentName.DataBind();
                ddlAgentName.Enabled = false;
            }

            //ddl_ProductGroup
            List <dbo_ProductClass> ProductGroup = dbo_ProductDataClass.Search(string.Empty, string.Empty, string.Empty, null, string.Empty).GroupBy(f => f.Product_group_ID).Select(grb => grb.First()).ToList();
            dbo_ProductClass        b            = new dbo_ProductClass();
            dbo_ProductClass        c1           = new dbo_ProductClass();
            b.Product_group_ID  = "เลือกทั้งหมด";
            c1.Product_group_ID = "อื่นๆ";
            ProductGroup.Insert(0, b);
            ProductGroup.Insert(ProductGroup.Count, c1);
            ddl_ProductGroup.DataSource = ProductGroup;
            ddl_ProductGroup.DataBind();
            ddl_ProductGroup.SelectedIndex = 0;


            ddl_Size.Items.Insert(0, "เลือกทั้งหมด");
            ddl_Size.SelectedIndex = 0;
            ddlProductName.Items.Insert(0, "เลือกทั้งหมด");
            ddlProductName.SelectedIndex = 0;

            txtInvoiceDateFrom.Text = DateTime.Now.ToShortDateString();
            txtInvoiceDateTo.Text   = DateTime.Now.ToShortDateString();
        }
        catch (Exception ex)
        {
            logger.Error(ex);
        }
    }
Beispiel #6
0
    public static List <dbo_ProductClass> GetOtherRequisitionByProductGroupID_View(String User_ID, DateTime?Requisition_Date, String Product_group_ID, String CV_Code, string Requisition_No)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        dbo_ProductClass clsdbo_Product  = new dbo_ProductClass();
        SqlConnection    connection      = SAMDataClass.GetConnection();
        string           selectProcedure = "GetOtherRequisitionByProductGroupID_View";
        SqlCommand       selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;


        if (!string.IsNullOrEmpty(User_ID))
        {
            selectCommand.Parameters.AddWithValue("@User_ID", User_ID);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@User_ID", DBNull.Value);
        }
        if (Requisition_Date.HasValue)
        {
            selectCommand.Parameters.AddWithValue("@Requisition_Date", Requisition_Date);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Requisition_Date", DBNull.Value);
        }
        if (!string.IsNullOrEmpty(Product_group_ID))
        {
            selectCommand.Parameters.AddWithValue("@Product_group_ID", Product_group_ID);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Product_group_ID", DBNull.Value);
        }
        if (!string.IsNullOrEmpty(CV_Code))
        {
            selectCommand.Parameters.AddWithValue("@CV_Code", CV_Code);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@CV_Code", DBNull.Value);
        }
        if (!string.IsNullOrEmpty(Requisition_No))
        {
            selectCommand.Parameters.AddWithValue("@Requisition_No", Requisition_No);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Requisition_No", DBNull.Value);
        }

        List <dbo_ProductClass> item = new List <dbo_ProductClass>();
        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);


                Int16? prevSize         = -1;
                String prevPacking_Size = string.Empty;



                int index = 1;
                foreach (DataRow reader in dt.Rows)
                {
                    if ((prevSize != (Int16?)reader["Size"] || prevPacking_Size != (reader["Unit_of_item_ID"]).ToString()) && Product_group_ID != "อื่นๆ")
                    {
                        item.Add(new dbo_ProductClass()
                        {
                            Product_ID = "Merge",

                            Product_Name = string.Format("{0} ({1}{2}/ลัง)", ((Int16?)reader["Size"]).ToString() + " CC.", (reader["Packing_Size"]).ToString(), (reader["Unit_of_item_ID"]).ToString())
                            ,
                            index = 1
                        });

                        index = 1;
                    }


                    item.Add(new dbo_ProductClass()
                    {
                        index            = index++,
                        Product_ID       = reader["Product_ID"] is DBNull ? null : reader["Product_ID"].ToString(),
                        Product_Name     = reader["Product_Name"] is DBNull ? null : reader["Product_Name"].ToString(),
                        Size             = reader["Size"] is DBNull ? null : (Int16?)reader["Size"],
                        Unit_of_item_ID  = reader["Unit_of_item_ID"] is DBNull ? null : reader["Unit_of_item_ID"].ToString(),
                        Product_group_ID = reader["Product_group_ID"] is DBNull ? null : reader["Product_group_ID"].ToString(),
                        Agent_Price      = reader["Agent_Price"] is DBNull ? null : (Decimal?)reader["Agent_Price"],
                        Vat                         = reader["Vat"] is DBNull ? null : (Byte?)reader["Vat"],
                        Order_No                    = 0,
                        Packing_Size                = 0,
                        Status                      = null,
                        Total_Qty                   = reader["Requisition_Qty"] is DBNull ? null : (Int16?)reader["Requisition_Qty"],
                        Stock                       = reader["Stock"] is DBNull ? null : (Int16?)reader["Stock"],
                        Stock_on_Hand_ID            = reader["Stock_on_Hand_ID"] is DBNull ? null : reader["Stock_on_Hand_ID"].ToString(),
                        Other_Requisition_Detail_ID = reader["Other_Requisition_Detail_ID"] is DBNull ? null : reader["Other_Requisition_Detail_ID"].ToString()
                    });

                    prevPacking_Size = (reader["Unit_of_item_ID"]).ToString();
                    prevSize         = reader["Size"] is DBNull ? null : (Int16?)reader["Size"];
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(item);
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
Beispiel #7
0
    public static List <dbo_ProductClass> SelectRequisitionByProductGroupID(String Product_group_ID, String Requisition_No)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        dbo_ProductClass clsdbo_Product  = new dbo_ProductClass();
        SqlConnection    connection      = SAMDataClass.GetConnection();
        string           selectProcedure = "SelectRequisitionByProductGroupID";
        SqlCommand       selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;


        if (!string.IsNullOrEmpty(Product_group_ID))
        {
            selectCommand.Parameters.AddWithValue("@Product_group_ID", Product_group_ID);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Product_group_ID", DBNull.Value);
        }
        if (!string.IsNullOrEmpty(Requisition_No))
        {
            selectCommand.Parameters.AddWithValue("@Requisition_No", Requisition_No);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Requisition_No", DBNull.Value);
        }


        //if (!string.IsNullOrEmpty(CV_Code))
        //{
        //    selectCommand.Parameters.AddWithValue("@CV_Code", CV_Code);
        //}
        //else
        //{
        //    selectCommand.Parameters.AddWithValue("@CV_Code", DBNull.Value);
        //}
        List <dbo_ProductClass> item = new List <dbo_ProductClass>();
        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);


                Int16?prevSize = -1;
                int   index    = 0;
                foreach (DataRow reader in dt.Rows)
                {
                    if (prevSize != (Int16?)reader["Size"] && Product_group_ID != "อื่นๆ")
                    {
                        item.Add(new dbo_ProductClass()
                        {
                            Product_ID   = "Merge",
                            Product_Name = ((Int16?)reader["Size"]).ToString() + " CC."
                        });
                    }


                    item.Add(new dbo_ProductClass()
                    {
                        index            = index++,
                        Product_ID       = reader["Product_ID"] is DBNull ? null : reader["Product_ID"].ToString(),
                        Product_Name     = reader["Product_Name"] is DBNull ? null : reader["Product_Name"].ToString(),
                        Size             = reader["Size"] is DBNull ? null : (Int16?)reader["Size"],
                        Unit_of_item_ID  = reader["Unit_of_item_ID"] is DBNull ? null : reader["Unit_of_item_ID"].ToString(),
                        Product_group_ID = reader["Product_group_ID"] is DBNull ? null : reader["Product_group_ID"].ToString(),
                        CP_Meiji_Price   = reader["CP_Meiji_Price"] is DBNull ? null : (Decimal?)reader["CP_Meiji_Price"],
                        Point            = reader["Point"] is DBNull ? null : (Byte?)reader["Point"],
                        Photo            = reader["Photo"] is DBNull ? null : (byte[])reader["Photo"],

                        //   Exclude_Vat = reader["Exclude_Vat"] is DBNull ? null : (Boolean?)reader["Exclude_Vat"],



                        Vat                = reader["Vat"] is DBNull ? null : (Byte?)reader["Vat"],
                        Order_No           = reader["Order_No"] is DBNull ? null : (Byte?)reader["Order_No"],
                        Quantity_in__carte = reader["Quantity_in__carte"] is DBNull ? null : (Byte?)reader["Quantity_in__carte"],
                        Packing_Size       = reader["Packing_Size"] is DBNull ? null : (Byte?)reader["Packing_Size"],

                        Status = reader["Status"] is DBNull ? null : reader["Status"].ToString(),

                        Quantity = reader["Quantity"] is DBNull ? 0 : (Int32?)reader["Quantity"],


                        Agent_Price = reader["Agent_Price"] is DBNull ? null : (Decimal?)reader["Agent_Price"],
                        //    Total = reader["Total"] is DBNull ? null : (Decimal?)reader["Total"]
                    });



                    prevSize = reader["Size"] is DBNull ? null : (Int16?)reader["Size"];
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(item);
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
Beispiel #8
0
    public static List <dbo_ProductClass> GetRequisitionByProductGroupID(String User_ID, String Requisition_No, String Product_group_ID, String Time_No)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        dbo_ProductClass clsdbo_Product  = new dbo_ProductClass();
        SqlConnection    connection      = SAMDataClass.GetConnection();
        string           selectProcedure = "GetRequisitionByProductGroupID_View";
        SqlCommand       selectCommand   = new SqlCommand(selectProcedure, connection);

        selectCommand.CommandType = CommandType.StoredProcedure;


        if (!string.IsNullOrEmpty(User_ID))
        {
            selectCommand.Parameters.AddWithValue("@User_ID", User_ID);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@User_ID", DBNull.Value);
        }
        if (!string.IsNullOrEmpty(Requisition_No))
        {
            selectCommand.Parameters.AddWithValue("@Requisition_No", Requisition_No);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Requisition_No", DBNull.Value);
        }
        if (!string.IsNullOrEmpty(Product_group_ID))
        {
            selectCommand.Parameters.AddWithValue("@Product_group_ID", Product_group_ID);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Product_group_ID", DBNull.Value);
        }
        if (!string.IsNullOrEmpty(Time_No))
        {
            selectCommand.Parameters.AddWithValue("@Time_No", Time_No);
        }
        else
        {
            selectCommand.Parameters.AddWithValue("@Time_No", DBNull.Value);
        }



        List <dbo_ProductClass> item = new List <dbo_ProductClass>();
        DataTable dt = new DataTable();

        try
        {
            connection.Open();
            SqlDataReader reader1 = selectCommand.ExecuteReader();
            if (reader1.HasRows)
            {
                dt.Load(reader1);

                String prevPacking_Size = string.Empty;
                String prevUnitItem     = string.Empty;
                String prevProduct      = string.Empty;;
                Int16? prevSize         = -1;

                int index = 1;
                foreach (DataRow reader in dt.Rows)
                {
                    if ((prevSize != (Int16?)reader["Size"] || prevPacking_Size != (reader["Packing_Size"]).ToString() || prevUnitItem != (reader["Unit_of_item_ID"]).ToString()) && Product_group_ID != "อื่นๆ")
                    {
                        item.Add(new dbo_ProductClass()
                        {
                            Product_ID = "Merge",

                            Product_Name = string.Format("{0} ({1}{2}/ลัง)", ((Int16?)reader["Size"]).ToString() + " CC.", (reader["Packing_Size"]).ToString(), (reader["Unit_of_item_ID"]).ToString())
                            ,
                            index = 1
                        });
                        index = 1;
                    }

                    if (prevProduct != (string)reader["Product_ID"])
                    {
                        item.Add(new dbo_ProductClass()
                        {
                            index           = index++,
                            Product_ID      = reader["Product_ID"] is DBNull ? null : reader["Product_ID"].ToString(),
                            Product_Name    = reader["Product_Name"] is DBNull ? null : reader["Product_Name"].ToString(),
                            Size            = reader["Size"] is DBNull ? null : (Int16?)reader["Size"],
                            Unit_of_item_ID = reader["Unit_of_item_ID"] is DBNull ? null : reader["Unit_of_item_ID"].ToString(),

                            Product_group_ID = reader["Product_group_ID"] is DBNull ? null : reader["Product_group_ID"].ToString(),

                            SP_Price       = reader["SP_Price"] is DBNull ? null : (Decimal?)reader["SP_Price"],
                            CP_Meiji_Price = reader["CP_Meiji_Price"] is DBNull ? null : (Decimal?)reader["CP_Meiji_Price"],


                            Point = reader["Point"] is DBNull ? 0 : (Byte?)reader["Point"],


                            Vat                   = reader["Vat"] is DBNull ? 0 : (Byte?)reader["Vat"],
                            Order_No              = 0,
                            Packing_Size          = 0,
                            Status                = null,
                            Total_Qty             = reader["Total_Qty"] is DBNull ? 0 : (Int16?)reader["Total_Qty"],
                            Deposit_Qty           = reader["Deposit_Qty"] is DBNull ? 0 : (Int16?)reader["Deposit_Qty"],
                            Sub_Total_Qty         = reader["Sub_Total_Qty"] is DBNull ? 0 : (Int16?)reader["Sub_Total_Qty"],
                            Suggestion_Qty        = reader["Suggestion_Qty"] is DBNull ? 0 : (Int16?)reader["Suggestion_Qty"],
                            Requisition_Qty       = reader["Requisition_Qty"] is DBNull ? 0 : (Int16?)reader["Requisition_Qty"],
                            Previous_Balance_Qty  = reader["Previous_Balance_Qty"] is DBNull ? 0 : (Int16?)reader["Previous_Balance_Qty"],
                            Requisition_Detail_ID = reader["Requisition_Detail_ID"] is DBNull ? null : reader["Requisition_Detail_ID"].ToString(),
                            Start_Effective_Date  = reader["Start_Effective_Date"] is DBNull ? DateTime.Now.AddYears(-1) : (DateTime?)reader["Start_Effective_Date"]
                        });
                    }

                    prevPacking_Size = (reader["Packing_Size"]).ToString();
                    prevUnitItem     = (reader["Unit_of_item_ID"]).ToString();
                    prevSize         = reader["Size"] is DBNull ? null : (Int16?)reader["Size"];
                    prevProduct      = reader["Product_ID"] is DBNull ? null : (string)reader["Product_ID"];
                }
            }
            reader1.Close();
        }
        catch (SqlException ex)
        {
            logger.Error(ex.Message);
            return(item);
        }
        catch (Exception ex)
        {
        }
        finally
        {
            connection.Close();
        }
        return(item);
    }
Beispiel #9
0
    private void SetUpDrowDownList()
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        try
        {
            string        User_ID    = Request.Cookies["User_ID"].Value;
            dbo_UserClass user_class = dbo_UserDataClass.Select_Record(User_ID);
            if (user_class.User_Group_ID == "CP Meiji")
            {
                String   strString = user_class.Region;
                String[] myArr     = strString.Split(',');
                //ddlAgentName
                List <dbo_AgentClass> agent = dbo_AgentDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, "Active", string.Empty);
                String[] agent_tmp1         = agent.Where(f => f.DM_ID == User_ID || f.GM_ID == User_ID.Trim() || f.SD_ID == User_ID.Trim() || f.SM_ID == User_ID.Trim() || f.APV_ID == User_ID.Trim()).Select(f => f.CV_Code).ToArray();
                String[] agent_tmp          = agent.Where(f => myArr.Contains(f.Location_Region)).OrderBy(f => f.AgentName).Select(f => f.CV_Code).ToArray();

                List <dbo_UserClass> users = dbo_UserDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty
                                                                      , string.Empty, string.Empty, string.Empty, string.Empty, null, string.Empty, string.Empty);
                users.Where(f => f.User_Group_ID == "Agent" && f.Status == "Active" && f.Position == "สาวส่งนม" || f.Position == "ซุปเปอร์ไวซ์เซอร์").OrderBy(f => f.AgentName);

                if (agent_tmp1.Length > 0)
                {
                    ddl_SPName.DataSource = users.Where(f => agent_tmp1.Contains(f.CV_CODE)).OrderBy(f => f.FullName_ddl);
                    ddl_SPName.DataBind();
                    ddl_SPName.Items.Insert(0, "เลือกทั้งหมด");
                }
                else
                {
                    ddl_SPName.DataSource = users.Where(f => agent_tmp.Contains(f.CV_CODE)).OrderBy(f => f.FullName_ddl);
                    ddl_SPName.DataBind();
                    ddl_SPName.Items.Insert(0, "เลือกทั้งหมด");
                }
            }
            else
            {
                //ddl_SPName
                List <dbo_UserClass> users = dbo_UserDataClass.Search(string.Empty, string.Empty, string.Empty, string.Empty
                                                                      , string.Empty, string.Empty, string.Empty, user_class.CV_CODE.Trim(), null, string.Empty, string.Empty);

                users.Where(f => f.User_Group_ID == "Agent" && f.Status == "Active" && f.Position == "สาวส่งนม" || f.Position == "ซุปเปอร์ไวซ์เซอร์").OrderBy(f => f.AgentName);

                ddl_SPName.DataSource = users.OrderBy(f => f.FullName_ddl);
                ddl_SPName.DataBind();
                ddl_SPName.Items.Insert(0, "เลือกทั้งหมด");
            }

            //ddl_ProductGroup
            List <dbo_ProductClass> ProductGroup = dbo_ProductDataClass.Search(string.Empty, string.Empty, string.Empty, null, string.Empty).GroupBy(f => f.Product_group_ID).Select(grb => grb.First()).ToList();
            dbo_ProductClass        b            = new dbo_ProductClass();
            dbo_ProductClass        c1           = new dbo_ProductClass();
            b.Product_group_ID  = "เลือกทั้งหมด";
            c1.Product_group_ID = "อื่นๆ";
            ProductGroup.Insert(0, b);
            ProductGroup.Insert(ProductGroup.Count, c1);
            ddl_ProductGroup.DataSource = ProductGroup;
            ddl_ProductGroup.DataBind();

            ddl_Size.Items.Insert(0, "เลือกทั้งหมด");
            ddl_Size.SelectedIndex = 0;

            RequisitionDate_From.Text = DateTime.Now.ToShortDateString();
            RequisitionDate_To.Text   = DateTime.Now.ToShortDateString();
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
Beispiel #10
0
 private void SetData(dbo_ProductClass clsdbo_Product)
 {
     //if (string.IsNullOrEmpty(txtProduct_ID.Text))
     //{
     //    clsdbo_Product.Product_ID = null;
     //}
     //else
     //{
     //    clsdbo_Product.Product_ID = txtProduct_ID.Text;
     //}
     if (string.IsNullOrEmpty(txtProduct_Name.Text))
     {
         clsdbo_Product.Product_Name = null;
     }
     else
     {
         clsdbo_Product.Product_Name = txtProduct_Name.Text;
     }
     //if (string.IsNullOrEmpty(txtSize.Text))
     //{
     //    clsdbo_Product.Size = null;
     //}
     //else
     //{
     //    clsdbo_Product.Size = System.Convert.ToInt16(txtSize.Text);
     //}
     //if (string.IsNullOrEmpty(txtUnit_of_item_ID.Text))
     //{
     //    clsdbo_Product.Unit_of_item_ID = null;
     //}
     //else
     //{
     //    clsdbo_Product.Unit_of_item_ID = txtUnit_of_item_ID.Text;
     //}
     //if (string.IsNullOrEmpty(txtProduct_group_ID.Text))
     //{
     //    clsdbo_Product.Product_group_ID = null;
     //}
     //else
     //{
     //    clsdbo_Product.Product_group_ID = txtProduct_group_ID.Text;
     //}
     //if (string.IsNullOrEmpty(txtEAN.Text))
     //{
     //    clsdbo_Product.EAN = null;
     //}
     //else
     //{
     //    clsdbo_Product.EAN = txtEAN.Text;
     //}
     if (string.IsNullOrEmpty(txtCP_Meiji_Price.Text))
     {
         clsdbo_Product.CP_Meiji_Price = null;
     }
     else
     {
         clsdbo_Product.CP_Meiji_Price = System.Convert.ToDecimal(txtCP_Meiji_Price.Text);
     }
     if (string.IsNullOrEmpty(txtPoint.Text))
     {
         clsdbo_Product.Point = null;
     }
     else
     {
         clsdbo_Product.Point = System.Convert.ToByte(txtPoint.Text);
     }
     // clsdbo_Product.Exclude_Vat = txtExclude_Vat.Checked ? true : false;
     if (string.IsNullOrEmpty(txtVat.Text))
     {
         clsdbo_Product.Vat = null;
     }
     else
     {
         clsdbo_Product.Vat = System.Convert.ToByte(txtVat.Text);
     }
     //if (string.IsNullOrEmpty(txtOrder_No.Text))
     //{
     //    clsdbo_Product.Order_No = null;
     //}
     //else
     //{
     //    clsdbo_Product.Order_No = System.Convert.ToInt16(txtOrder_No.Text);
     //}
     //if (string.IsNullOrEmpty(txtQuantity_in__carte.Text))
     //{
     //    clsdbo_Product.Quantity_in__carte = null;
     //}
     //else
     //{
     //    clsdbo_Product.Quantity_in__carte = System.Convert.ToByte(txtQuantity_in__carte.Text);
     //}
     //if (string.IsNullOrEmpty(txtPacking_Size.Text))
     //{
     //    clsdbo_Product.Packing_Size = null;
     //}
     //else
     //{
     //    clsdbo_Product.Packing_Size = System.Convert.ToByte(txtPacking_Size.Text);
     //}
     // clsdbo_Product.Status = txtStatus.Checked ? true : false;
 }
Beispiel #11
0
 private void InsertRecord()
 {
     dbo_ProductClass clsdbo_Product = new dbo_ProductClass();
 }
Beispiel #12
0
    private void SetData(dbo_ProductClass clsdbo_Product)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);
        try
        {
            if (string.IsNullOrEmpty(txtProduct_ID.Text))
            {
                clsdbo_Product.Product_ID = null;
            }
            else
            {
                clsdbo_Product.Product_ID = txtProduct_ID.Text;
            }
            if (string.IsNullOrEmpty(txtProduct_Name.Text))
            {
                clsdbo_Product.Product_Name = null;
            }
            else
            {
                clsdbo_Product.Product_Name = txtProduct_Name.Text;
            }
            if (string.IsNullOrEmpty(txtSize.Text))
            {
                clsdbo_Product.Size = null;
            }
            else
            {
                clsdbo_Product.Size = System.Convert.ToInt16(txtSize.Text);
            }

            if (string.IsNullOrEmpty(txtCP_Meiji_Price.Text))
            {
                clsdbo_Product.CP_Meiji_Price = null;
            }
            else
            {
                clsdbo_Product.CP_Meiji_Price = System.Convert.ToDecimal(txtCP_Meiji_Price.Text);
            }
            if (string.IsNullOrEmpty(txtPoint.Text))
            {
                clsdbo_Product.Point = null;
            }
            else
            {
                clsdbo_Product.Point = System.Convert.ToByte(txtPoint.Text);
            }
            if (string.IsNullOrEmpty(txtVat.Text))
            {
                clsdbo_Product.Vat = null;
            }
            else
            {
                clsdbo_Product.Vat = System.Convert.ToByte(txtVat.Text);
            }
            if (string.IsNullOrEmpty(txtOrder_No.Text))
            {
                clsdbo_Product.Order_No = null;
            }
            else
            {
                clsdbo_Product.Order_No = System.Convert.ToInt16(txtOrder_No.Text);
            }

            if (string.IsNullOrEmpty(txtPacking_Size.Text))
            {
                clsdbo_Product.Packing_Size = null;
            }
            else
            {
                clsdbo_Product.Packing_Size = System.Convert.ToByte(txtPacking_Size.Text);
            }

            if (string.IsNullOrEmpty(txtSAPProductCode.Text))
            {
                clsdbo_Product.SAP_Product_Code = null;
            }
            else
            {
                clsdbo_Product.SAP_Product_Code = txtSAPProductCode.Text;
            }


            if (string.IsNullOrEmpty(txtAgentPrice.Text))
            {
                clsdbo_Product.Agent_Price = null;
            }
            else
            {
                clsdbo_Product.Agent_Price = System.Convert.ToDecimal(txtAgentPrice.Text);
            }


            if (string.IsNullOrEmpty(txtSPPrice.Text))
            {
                clsdbo_Product.SP_Price = null;
            }
            else
            {
                clsdbo_Product.SP_Price = System.Convert.ToDecimal(txtSPPrice.Text);
            }



            clsdbo_Product.Product_group_ID = ddlProduct_group_ID.SelectedValue;
            clsdbo_Product.Unit_of_item_ID  = ddlUnit_of_item_ID.SelectedValue;
            clsdbo_Product.Status           = ddlStatus.SelectedValue;



            if (Session["FileBytes"] != null)
            {
                clsdbo_Product.Photo = (byte[])Session["FileBytes"];
                Session.Remove("FileBytes");
            }
            else
            {
                clsdbo_Product.Photo = null;
            }
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }
Beispiel #13
0
    private void GetDetailsDataToForm(string id, string Mode)
    {
        logger.Info(HttpContext.Current.Request.Cookies["User_ID"].Value + " " + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString() + " " + System.Reflection.MethodBase.GetCurrentMethod().Name);

        showPanel("pnlForm");

        txtProduct_ID.Text     = string.Empty;
        txtProduct_Name.Text   = string.Empty;
        txtSize.Text           = string.Empty;
        txtCP_Meiji_Price.Text = string.Empty;
        txtPoint.Text          = string.Empty;
        txtVat.Text            = string.Empty;
        txtOrder_No.Text       = string.Empty;
        txtPacking_Size.Text   = string.Empty;
        txtSAPProductCode.Text = string.Empty;
        txtAgentPrice.Text     = string.Empty;
        txtSPPrice.Text        = string.Empty;

        ddlProduct_group_ID.ClearSelection();
        ddlUnit_of_item_ID.ClearSelection();
        ddlStatus.ClearSelection();
        imgProductPhoto.ImageUrl = String.Empty;

        try
        {
            if (!string.IsNullOrEmpty(id))
            {
                dbo_ProductClass products = dbo_ProductDataClass.Select_Record(id);

                txtProduct_ID.Text     = products.Product_ID;
                txtProduct_Name.Text   = products.Product_Name;
                txtVat.Text            = products.Vat.ToString();
                txtOrder_No.Text       = products.Order_No.ToString();
                txtPacking_Size.Text   = products.Packing_Size.ToString();
                txtSize.Text           = products.Size.ToString();
                txtCP_Meiji_Price.Text = products.CP_Meiji_Price.ToString();
                txtPoint.Text          = products.Point.ToString();

                txtSAPProductCode.Text = products.SAP_Product_Code;
                txtAgentPrice.Text     = products.Agent_Price.ToString();
                txtSPPrice.Text        = products.SP_Price.ToString();



                if (ddlProduct_group_ID.Items.FindByText(products.Product_group_ID) != null)
                {
                    ddlProduct_group_ID.Items.FindByText(products.Product_group_ID).Selected = true;
                }

                if (ddlUnit_of_item_ID.Items.FindByText(products.Unit_of_item_ID) != null)
                {
                    ddlUnit_of_item_ID.Items.FindByText(products.Unit_of_item_ID).Selected = true;
                }

                if (ddlStatus.Items.FindByText(products.Status) != null)
                {
                    ddlStatus.Items.FindByText(products.Status).Selected = true;
                }

                if (products.Photo != null)
                {
                    string base64String = Convert.ToBase64String(products.Photo, 0, products.Photo.Length);
                    imgProductPhoto.ImageUrl = "data:image/jpeg;base64," + base64String;
                }
            }

            bool enable = Mode != "View";

            txtProduct_ID.Enabled     = false;
            txtProduct_Name.Enabled   = enable;
            txtSize.Enabled           = enable;
            txtCP_Meiji_Price.Enabled = enable;
            txtPoint.Enabled          = enable;
            txtVat.Enabled            = enable;

            txtPacking_Size.Enabled     = enable;
            ddlProduct_group_ID.Enabled = enable;
            ddlUnit_of_item_ID.Enabled  = enable;
            txtSAPProductCode.Enabled   = enable;
            txtSPPrice.Enabled          = enable;
            txtImage.Enabled            = enable;

            txtAgentPrice.Enabled = enable;
            ddlStatus.Enabled     = enable;
            txtOrder_No.Enabled   = enable;

            // AsyncFileUpload1.Enabled = enable;
            spanImage.Visible = enable;

            if (Mode == "View")
            {
                btnSave.Visible   = true;
                btnSave.Text      = "แก้ไข";
                btnCancel.Text    = "กลับไปหน้าค้นหา";
                btnSaveMode.Value = "บันทึก";
                //AsyncFileUpload1.Enabled = false;
            }
            else if (Mode == "Edit")
            {
                btnSave.Visible   = true;
                btnSave.Text      = "บันทึก";
                btnCancel.Text    = "ยกเลิก";
                btnSaveMode.Value = "แก้ไข";
                //AsyncFileUpload1.Enabled = true;
            }
            else if (string.IsNullOrEmpty(Mode))
            {
                btnSave.Visible       = true;
                btnSave.Text          = "บันทึก";
                btnCancel.Text        = "ยกเลิก";
                btnSaveMode.Value     = "บันทึก";
                txtProduct_ID.Enabled = true;
                //AsyncFileUpload1.Enabled = enable;
                imgProductPhoto.ImageUrl = "";
                //List<dbo_ProductClass> order_ = dbo_ProductDataClass.Search(string.Empty, string.Empty, 0, string.Empty);
                //txtOrder_No.Text = (order_.Max(f => f.Order_No).Value + 1).ToString();
            }
        }
        catch (Exception ex)
        {
            logger.Error(ex.Message);
        }
    }