예제 #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);
        }
예제 #2
0
        //muiBtnOK_Click
        private void muiBtnOK_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var product = CheckInput();

                if (product != null)
                {
                    if (bus_tb_product.InsertProduct(product, StaticClass.GeneralClass.flag_database_type_general) == 1)
                    {
                        if (!System.IO.Directory.Exists(current_directory + @"\images"))
                        {
                            System.IO.Directory.CreateDirectory(current_directory + @"\images");
                        }
                        if (path_image != "")
                        {
                            System.IO.File.Copy(path_image, current_directory + @"\images\" + (product.ProductID).ToString() + @".png", true);
                        }

                        //insert history
                        EC_tb_InputHistory history = new EC_tb_InputHistory();
                        history.ProductID      = product.ProductID;
                        history.ProductName    = product.ShortName;
                        history.InputDate      = System.DateTime.Now.ToString();
                        history.UserID         = StaticClass.GeneralClass.id_user_general;
                        history.UserName       = StaticClass.GeneralClass.name_user_general;
                        history.Cost           = product.Cost;
                        history.Price          = product.Price;
                        history.InventoryCount = product.InventoryCount;
                        history.CategoryID     = product.CategoryID;
                        history.CategoryName   = StaticClass.GeneralClass.HandlingSpecialCharacter(category_name);
                        history.Tax            = product.Tax;
                        history.Active         = product.Active;
                        history.Country        = product.Country;
                        history.SizeWeight     = product.SizeWeight;

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

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