Ejemplo n.º 1
0
        //InSertAllProduct
        private int InSertAllProduct(DataTable tb_product)
        {
            int result = 0;

            foreach (DataRow datarow in tb_product.Rows)
            {
                if (datarow[0].ToString() != "")
                {
                    CashierRegisterEntity.EC_tb_Product ec_tb_product = new CashierRegisterEntity.EC_tb_Product();
                    ec_tb_product.ProductID  = Convert.ToInt32(datarow[0].ToString());
                    ec_tb_product.BarcodeID  = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[1].ToString());
                    ec_tb_product.ShortName  = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[2].ToString());
                    ec_tb_product.LongName   = StaticClass.GeneralClass.HandlingSpecialCharacter(datarow[3].ToString());
                    ec_tb_product.Price      = Convert.ToDecimal(datarow[4].ToString());
                    ec_tb_product.CategoryID = Convert.ToInt32(datarow[5].ToString());
                    ec_tb_product.Tax        = Convert.ToInt32(datarow[6].ToString());
                    ec_tb_product.PathImage  = datarow[7].ToString();
                    ec_tb_product.Capture    = Convert.ToInt32(datarow[8].ToString());
                    ec_tb_product.Active     = Convert.ToInt32(datarow[9].ToString());

                    if (bus_tb_product.InsertProduct(ec_tb_product, StaticClass.GeneralClass.flag_database_type_general) == 1)
                    {
                        result++;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        //muiBtnOK_Click
        private void muiBtnOK_Click(object sender, RoutedEventArgs e)
        {
            if (StaticClass.GeneralClass.list_ec_tb_product_general.Count == 0)
            {
                tblNotification.Text = FindResource("select_least_product").ToString();
            }
            else
            {
                try
                {
                    int result = 0;
                    for (int i = 0; i < StaticClass.GeneralClass.list_ec_tb_product_general.Count; i++)
                    {
                        if (bus_tb_orderdetail.GetOrderDetail("WHERE [ProductID]=" + StaticClass.GeneralClass.list_ec_tb_product_general[i].ProductID.ToString()).Rows.Count > 0)
                        {
                            tblNotification.Text = FindResource("product").ToString() + " " + StaticClass.GeneralClass.list_ec_tb_product_general[i].ShortName.ToString() + " " + FindResource("already_uses").ToString();
                        }
                        else
                        {
                            CashierRegisterEntity.EC_tb_Product ec_tb_product = new CashierRegisterEntity.EC_tb_Product();
                            ec_tb_product.ProductID = StaticClass.GeneralClass.list_ec_tb_product_general[i].ProductID;
                            if (bus_tb_product.DeleteProduct(ec_tb_product) == 1)
                            {
                                if (System.IO.File.Exists(StaticClass.GeneralClass.list_ec_tb_product_general[i].PathImage))
                                {
                                    System.IO.File.Delete(StaticClass.GeneralClass.list_ec_tb_product_general[i].PathImage);
                                }
                                result++;
                            }
                        }
                    }

                    if (result > 0)
                    {
                        if (muibtndelete_delegate != null)
                        {
                            StaticClass.GeneralClass.flag_add_edit_delete_product_general = true;
                            muibtndelete_delegate(true);
                            this.Close();
                        }
                    }
                    StaticClass.GeneralClass.list_ec_tb_product_general.Clear();
                }
                catch (Exception ex)
                {
                    tblNotification.Text = ex.Message;
                }
            }
        }
Ejemplo n.º 3
0
        //muiBtnOK_Click
        private void muiBtnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (bus_tb_orderdetail.CheckExist(" Where CategoryID = " + StaticClass.GeneralClass.categoryid_general) != "")
                {
                    tblNotification.Text = FindResource("category_uses_existing").ToString();
                    return;
                }
                else
                {
                    EC_tb_Category ec_tb_category = new EC_tb_Category();

                    ec_tb_category.CategoryID = StaticClass.GeneralClass.categoryid_general;

                    if (bus_tb_category.DeleteCategory(ec_tb_category) == 1)
                    {
                        CashierRegisterEntity.EC_tb_Product ec_tb_product = new CashierRegisterEntity.EC_tb_Product();
                        ec_tb_product.CategoryID = StaticClass.GeneralClass.categoryid_general;

                        if (bus_tb_product.DeleteProductFromCategoryID(ec_tb_product) >= 0)
                        {
                            if (lbcategory_delete_delegate != null)
                            {
                                StaticClass.GeneralClass.flag_add_edit_delete_category_general = true;
                                lbcategory_delete_delegate(false);
                            }

                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                tblNotification.Text = ex.Message;
            }
        }
Ejemplo n.º 4
0
 public static int CompareProductInventoryCount(EC_tb_Product p1, EC_tb_Product p2)
 {
     return(p1.InventoryCount.CompareTo(p2.InventoryCount));
 }
Ejemplo n.º 5
0
        //check input data
        private CashierRegisterEntity.EC_tb_Product CheckInput()
        {
            CashierRegisterEntity.EC_tb_Product ec_tb_product = new CashierRegisterEntity.EC_tb_Product();

            try
            {
                if (txbShortName.Text == "")
                {
                    tblNotification.Text = FindResource("have_not_enter_short_name").ToString();
                    txbShortName.Focus();
                    return(null);
                }

                if (txbLongName.Text == "")
                {
                    tblNotification.Text = FindResource("have_not_enter_long_name").ToString();
                    txbLongName.Focus();
                    return(null);
                }

                if (txbCost.Text == "")
                {
                    tblNotification.Text = FindResource("have_not_enter_cost").ToString();
                    txbCost.Focus();
                    return(null);
                }

                double cost_temp;
                if (double.TryParse(txbCost.Text, NumberStyles.AllowDecimalPoint, StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0" ? new System.Globalization.CultureInfo("en-US") : new System.Globalization.CultureInfo("fr-FR"), out cost_temp) == false || cost_temp.ToString().Length > 12)
                {
                    tblNotification.Text = FindResource("cost_invalid").ToString();
                    txbCost.Focus();
                    return(null);
                }

                if (txbPrice.Text == "")
                {
                    tblNotification.Text = FindResource("have_not_enter_price").ToString();
                    txbPrice.Focus();
                    return(null);
                }

                double price_temp;
                if (double.TryParse(txbPrice.Text, NumberStyles.AllowDecimalPoint, StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0" ? new System.Globalization.CultureInfo("en-US") : new System.Globalization.CultureInfo("fr-FR"), out price_temp) == false || price_temp.ToString().Length > 12)
                {
                    tblNotification.Text = FindResource("price_invalid").ToString();
                    txbPrice.Focus();
                    return(null);
                }

                if (txbInventoryCount.Text == "")
                {
                    tblNotification.Text = FindResource("have_not_enter_inventory_count").ToString();
                    txbInventoryCount.Focus();
                    return(null);
                }

                double inventory_count_temp;
                if (double.TryParse(txbInventoryCount.Text, out inventory_count_temp) == false || inventory_count_temp.ToString().Length > 10)
                {
                    tblNotification.Text = FindResource("inventory_count_invalid").ToString();
                    txbInventoryCount.Focus();
                    return(null);
                }

                ec_tb_product.ProductID = bus_tb_product.GetMaxProductID("") + 1;
                ec_tb_product.Capture   = -1;

                if (chkTax.IsChecked == true)
                {
                    ec_tb_product.Tax = 1;
                }
                else
                {
                    ec_tb_product.Tax = 0;
                }

                if (chkActive.IsChecked == true)
                {
                    ec_tb_product.Active = 1;
                }
                else
                {
                    ec_tb_product.Active = 0;
                }

                if (path_image != "")
                {
                    ec_tb_product.PathImage = @"\images\" + ec_tb_product.ProductID.ToString() + @".png";
                }
                else
                {
                    ec_tb_product.PathImage = "";
                }

                ec_tb_product.Country    = StaticClass.GeneralClass.HandlingSpecialCharacter(txbCountry.Text.Trim().ToString());
                ec_tb_product.SizeWeight = StaticClass.GeneralClass.HandlingSpecialCharacter(txbSize_Weight.Text.Trim().ToString());

                ec_tb_product.BarcodeID  = txbBarcode.Text.Trim().ToString();
                ec_tb_product.ShortName  = StaticClass.GeneralClass.HandlingSpecialCharacter(txbShortName.Text.Trim().ToString());
                ec_tb_product.LongName   = StaticClass.GeneralClass.HandlingSpecialCharacter(txbLongName.Text.Trim().ToString());
                ec_tb_product.CategoryID = StaticClass.GeneralClass.categoryid_general;

                ec_tb_product.Cost           = Convert.ToDecimal(txbCost.Text, StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0" ? new CultureInfo("en-US") : new CultureInfo("fr-FR"));
                ec_tb_product.Price          = Convert.ToDecimal(txbPrice.Text, StaticClass.GeneralClass.app_settings["decimalSeparator"].ToString() == "0" ? new CultureInfo("en-US") : new CultureInfo("fr-FR"));
                ec_tb_product.InventoryCount = Convert.ToInt32(txbInventoryCount.Text);

                return(ec_tb_product);
            }
            catch (OverflowException)
            {
                tblNotification.Text = FindResource("inventory_count_invalid").ToString() + " (Max: 2147483647)";
                txbInventoryCount.Focus();
                return(null);
            }
            catch (Exception ex)
            {
                tblNotification.Text = ex.Message;
                return(null);
            }
        }
Ejemplo n.º 6
0
        //muiBtnOK_Click
        private void muiBtnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                CashierRegisterEntity.EC_tb_Product ec_tb_product = CheckInput();

                if (ec_tb_product != null)
                {
                    if (bus_tb_product.UpdateProduct(ec_tb_product, StaticClass.GeneralClass.flag_database_type_general) == 1)
                    {
                        if (path_image != "")
                        {
                            if (!System.IO.Directory.Exists(current_directory + @"\images"))
                            {
                                System.IO.Directory.CreateDirectory(current_directory + @"\images");
                            }

                            if (path_image != StaticClass.GeneralClass.productpathimage_general)
                            {
                                System.IO.File.Copy(path_image, current_directory + ec_tb_product.PathImage, true);
                            }
                        }

                        if ((barcodeid != txbBarcode.Text.Trim().ToString()) || (short_name != txbShortName.Text.Trim().ToString()) || (long_name != txbLongName.Text.Trim().ToString()) ||
                            (cost != txbCost.Text.Trim().ToString()) || (price != txbPrice.Text.Trim().ToString()) || (inventory_count != txbInventoryCount.Text.Trim().ToString()) != (country != txbCountry.Text.Trim().ToString()) ||
                            (size_weight != txbSize_Weight.Text.Trim().ToString()) || (tax != chkTax.IsChecked.Value) || (active != chkActive.IsChecked.Value))
                        {
                            //insert history
                            EC_tb_InputHistory history = new EC_tb_InputHistory();
                            history.ProductID      = ec_tb_product.ProductID;
                            history.ProductName    = ec_tb_product.ShortName;
                            history.InputDate      = System.DateTime.Now.ToString();
                            history.UserID         = StaticClass.GeneralClass.id_user_general;
                            history.UserName       = StaticClass.GeneralClass.name_user_general;
                            history.Cost           = ec_tb_product.Cost;
                            history.Price          = ec_tb_product.Price;
                            history.InventoryCount = ec_tb_product.InventoryCount;
                            history.CategoryID     = ec_tb_product.CategoryID;
                            history.CategoryName   = category_name;
                            history.Tax            = ec_tb_product.Tax;
                            history.Active         = ec_tb_product.Active;
                            history.Country        = ec_tb_product.Country;
                            history.SizeWeight     = ec_tb_product.SizeWeight;

                            bus_tb_input_history.InsertInputHistory(history, StaticClass.GeneralClass.flag_database_type_general);
                        }

                        if (btnedit_delegate != null)
                        {
                            StaticClass.GeneralClass.flag_add_edit_delete_product_general = true;
                            btnedit_delegate(true);
                            this.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                tblNotification.Text = ex.Message;
            }
        }