Ejemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            this.Hide();
            suppliers supplier = new suppliers();

            supplier.ShowDialog();
        }
Ejemplo n.º 2
0
        private void btnBack_Click_1(object sender, EventArgs e)
        {
            this.Hide();
            suppliers order = new suppliers();

            order.ShowDialog();
        }
Ejemplo n.º 3
0
        private void SuppEdit_Click(object sender, RoutedEventArgs e)
        {
            dataAccess data = new dataAccess();
            suppliers  supp = new suppliers();

            if (SupplierID.Text == "" || CompanyName.Text == "" || Address.Text == "" || City.Text == "" || Region.Text == "" ||
                Postal.Text == "" || Country.Text == "" || Email.Text == "" || Phone.Text == "")
            {
                MessageBox.Show("All Fields are required");
            }
            else
            {
                supp.Address     = Address.Text;
                supp.City        = City.Text;
                supp.CompanyName = CompanyName.Text;
                supp.Country     = Country.Text;
                supp.Email       = Email.Text;
                supp.Phone       = long.Parse(Phone.Text);
                supp.PostalCode  = int.Parse(Postal.Text);
                supp.Region      = Region.Text;
                supp.SupplierID  = int.Parse(SupplierID.Text);

                data.editSuppliers(supp);
                MessageBox.Show("Suppliers" + supp.CompanyName + " Modified Successfully");
            }
        }
Ejemplo n.º 4
0
        private void button3_Click(object sender, EventArgs e)
        {
            suppliers supplier = new suppliers();

            supplier.ShowDialog();
            //new Supplier.suppliers().Show();
        }
Ejemplo n.º 5
0
        private void BtnModify_Click(object sender, EventArgs e)
        {
            FrmAddModifyDelete modifyCustomerForm = new FrmAddModifyDelete
            {
                addproductsupplier = false,
                productsupplier    = productsupplier
            };
            DialogResult result = modifyCustomerForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                productsupplier = modifyCustomerForm.productsupplier;
                this.DisplayProductSupplier();
                //refresh the grid view
                dataGridView1.DataSource = Product_supplierDB.GetSuppliers();
            }
            else if (result == DialogResult.Retry)
            {
                this.GetProductSupplierId(productsupplier.ProductSupplierId);
                if (productsupplier != null)
                {
                    this.DisplayProductSupplier();
                }
                else
                {
                    this.ClearControls();
                }
            }
        }
Ejemplo n.º 6
0
        public async Task <IActionResult> Putsuppliers([FromRoute] string id, [FromBody] suppliers suppliers)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != suppliers.supplierid)
            {
                return(BadRequest());
            }

            _context.Entry(suppliers).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!suppliersExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Ejemplo n.º 7
0
        //Edit Suppliers
        public void editSuppliers(suppliers suppliers)
        {
            SqlConnection connection = new SqlConnection(
                ConfigurationManager.ConnectionStrings["POS.Properties.Settings.Setting"].ConnectionString
                );

            try
            {
                connection.Open();
                string query = "UPDATE Supplier SET CompanyName='" + suppliers.CompanyName + "'," +
                               "Address='" + suppliers.Address + "',City='" + suppliers.City + "',Region='" + suppliers.Region + "'," +
                               "PostalCode=" + suppliers.PostalCode + ",Country='" + suppliers.Country + "'," +
                               "Phone=" + suppliers.Phone + ",Email='" + suppliers.Email + "' " +
                               "WHERE SupplierID=" + suppliers.SupplierID + " ";

                using (cmd = new SqlCommand(query, connection))
                {
                    cmd.ExecuteNonQuery();
                }


                connection.Close();
            }
            catch (Exception e)
            {
                e.ToString();
            }
        }
Ejemplo n.º 8
0
        private void BtnModify_Click(object sender, EventArgs e)
        {
            var    cells  = dataGridView1.CurrentRow.Cells;
            string rowId  = cells[1].Value.ToString();
            string rowId1 = cells[2].Value.ToString();

            var selectedProductSupplierId         = Product_supplierDB.GetSuppliers(rowId, rowId1);
            FrmAddModifyDelete modifyCustomerForm = new FrmAddModifyDelete
            {
                addproductsupplier    = false,
                modifyproductsupplier = selectedProductSupplierId
            };
            DialogResult result = modifyCustomerForm.ShowDialog();

            if (result == DialogResult.OK)
            {
                productsupplier = modifyCustomerForm.productsupplier;
                //this.DisplayProductSupplier();
                //refresh the grid view
                dataGridView1.DataSource = Product_supplierDB.GetSuppliers();
            }
            //else if (result == DialogResult.Retry)
            //{
            //    this.GetProductSupplierId(productsupplier.ProductSupplierId);
            //    if (productsupplier != null)
            //        this.DisplayProductSupplier();
            //    else
            //        this.ClearControls();
            //}
        }
Ejemplo n.º 9
0
        private void lbl_supplier_Click(object sender, EventArgs e)
        {
            bool IsOpen   = false;
            int  tabcount = 0;

            foreach (Form f in Application.OpenForms)
            {
                if (f.Text == "suppliers")
                {
                    tabForms.SelectedTab = tabForms.TabPages[tabcount - 2];
                    IsOpen = true;
                    f.Focus();
                    break;
                }
                tabcount++;
            }



            if (IsOpen == false)
            {
                suppliers frm = new suppliers();
                frm.FormBorderStyle  = FormBorderStyle.None;
                frm.StartPosition    = FormStartPosition.Manual;
                frm.Location         = new Point((this.Width - frm.Width) / 2, this.Location.Y + (this.Height - frm.Height) / 2);
                this.pnlMain.Visible = false;
                frm.MdiParent        = this;

                frm.Show();
            }
        }
Ejemplo n.º 10
0
        private void btnBackView_Click(object sender, EventArgs e)
        {
            this.Hide();
            suppliers supplier = new suppliers();

            supplier.ShowDialog();
            this.Close();
        }
Ejemplo n.º 11
0
 private void GetProductSupplierId(int productSupplierID)
 {
     try
     {
         productsupplier = Product_supplierDB.GetProductSupplierId(productSupplierID);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, ex.GetType().ToString());
     }
 }
Ejemplo n.º 12
0
        public async Task <IActionResult> Postsuppliers([FromBody] suppliers suppliers)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.suppliers.Add(suppliers);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("Getsuppliers", new { id = suppliers.supplierid }, suppliers));
        }
Ejemplo n.º 13
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            FrmAddModifyDelete addproductsupplierform = new FrmAddModifyDelete
            {
                addproductsupplier = true
            };
            DialogResult result = addproductsupplierform.ShowDialog();

            if (result == DialogResult.OK)
            {
                productsupplier          = addproductsupplierform.productsupplier;
                dataGridView1.DataSource = Product_supplierDB.GetSuppliers();
            }
        }
Ejemplo n.º 14
0
        private void BtnAccept_Click(object sender, EventArgs e)
        {
            if (IsValidData())
            {
                if (addproductsupplier) // processing Add
                {
                    productsupplier = new suppliers();
                    this.PutProductSupplierData(productsupplier);

                    try
                    {
                        productsupplier.ProductSupplierId = Product_supplierDB.AddProductSupplier(productsupplier);
                        this.DialogResult = DialogResult.OK;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ex.GetType().ToString());
                    }
                }
                else // processing Modify
                {
                    suppliers newProductSupplier = new suppliers
                    {
                        ProductId  = Convert.ToInt32(txtProductID.Text),
                        SupplierId = Convert.ToInt32(txtSupplierID.Text)
                    };
                    PutProductSupplierData(newProductSupplier);

                    try
                    {
                        if (!Product_supplierDB.UpdateProductSupplier(modifyproductsupplier, newProductSupplier))
                        {
                            MessageBox.Show("Another user has updated or " +
                                            "deleted that product supplier ID.", "Database Error");
                            this.DialogResult = DialogResult.Retry;
                        }
                        else
                        {
                            productsupplier   = newProductSupplier;
                            this.DialogResult = DialogResult.OK;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ex.GetType().ToString());
                    }
                }
            }
        }
Ejemplo n.º 15
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsValidData())
            {
                if (addsupplier) // processing Add
                {
                    supplier = new Suppliers();
                    this.PutSupplier(supplier);

                    try
                    {
                        supplier.SupplierId = SuppliersDB.AddSupplier(supplier);
                        this.DialogResult   = DialogResult.OK;
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ex.GetType().ToString());
                    }
                }
                else // processing Modify
                {
                    suppliers newSupplier = new suppliers
                    {
                        SupplierId = supplier.SupplierId
                    };
                    this.PutSupplier(newSupplier);

                    try
                    {
                        if (!SuppliersDB.UpdateSupplier(supplier, newSupplier))
                        {
                            MessageBox.Show("Another user has updated or " +
                                            "deleted that  supplier ID.", "Database Error");
                            this.DialogResult = DialogResult.Retry;
                        }
                        else
                        {
                            supplier          = newSupplier;
                            this.DialogResult = DialogResult.OK;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, ex.GetType().ToString());
                    }
                }
            }
        }
Ejemplo n.º 16
0
        private void SuppDelete_Click(object sender, RoutedEventArgs e)
        {
            if (SupplierID.Text == "")
            {
                MessageBox.Show("Supplier ID field is Empty");
            }
            else
            {
                dataAccess data = new dataAccess();
                suppliers  supp = new suppliers();
                supp.SupplierID  = int.Parse(SupplierID.Text);
                supp.CompanyName = CompanyName.Text;

                data.deleteSuppliers(supp);
                MessageBox.Show("Supplier " + supp.CompanyName + " Removed Successfully");
            }
        }
Ejemplo n.º 17
0
        public IHttpActionResult createSupplier([FromBody] SuppliersViewModel model)
        {
            var logInUserName = RequestContext.Principal.Identity.Name;

            try
            {
                if (model.supplier_name != null)
                {
                    //IDictionary<string, string> values = JsonConvert.DeserializeObject<IDictionary<string, string>>(data);

                    var ct = new suppliers();
                    if (ct != null)
                    {
                        ct.id            = string.Concat("S-" + rd.Next(1000));
                        ct.supplier_name = model.supplier_name;
                        ct.phone_no      = model.phone;;
                        ct.email         = model.email;
                        ct.address       = model.address;
                        ct.state         = model.state;
                        ct.city          = model.city;
                        ct.reg_date      = DateTime.UtcNow;
                        db.supplier.Add(ct);
                        db.SaveChanges();
                        ulog.loguserActivities(logInUserName, "Register new supplier named: '" + model.supplier_name + "'");
                        return(Content(HttpStatusCode.OK, "Supplier has been successfully registered!"));
                    }
                    else
                    {
                        // ulog.loguserActivities(logInUserName, "supplier details not registered");
                        return(Content(HttpStatusCode.NotFound, "supplier details not registered"));
                    }
                }
                //S   ulog.loguserActivities(logInUserName, "supplier details not registered");
                return(Content(HttpStatusCode.NotFound, "ensure that all field values are supplied"));
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.BadRequest, "supplier details not registered: " + ex));
            }
        }
Ejemplo n.º 18
0
        public void deleteSuppliers(suppliers supp)
        {
            SqlConnection connection = new SqlConnection(
                ConfigurationManager.ConnectionStrings["POS.Properties.Settings.Setting"].ConnectionString
                );

            try
            {
                connection.Open();
                string query = "DELETE FROM Supplier WHERE SupplierID = @SupplierID";

                using (SqlCommand cmd = new SqlCommand(query, connection))
                {
                    cmd.Parameters.AddWithValue("@SupplierID", supp.SupplierID);
                    cmd.ExecuteNonQuery();
                }
                connection.Close();
            }
            catch (Exception e)
            {
                e.ToString();
            }
        }
Ejemplo n.º 19
0
 private void PutSupplier(suppliers newSupplier)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 20
0
        public JsonResult Ajax_Purchase_Order(ajax_model ajax_data)
        {
            ajax_model data = new ajax_model
            {
                name      = ajax_data.name,
                main_data = ajax_data.main_data,
            };
            Dictionary <string, int> supplier_and_quantity;
            string supplier_status = "NOT_OUT_OF_STOCK_IN_SUPPLIER";

            using (var db = new DataBaseContext())
            {
                int temp_item_ware_id = Int32.Parse(data.name);

                items_warehouse item_ware_obj = db.item_warehouses_repository.Where(it => it.items_warehouseId == temp_item_ware_id).FirstOrDefault();

                supplier_and_quantity = SEND_ORDER_TO_SUPPLIERS(item_ware_obj);

                // Add Total Quantity From Suppliers
                foreach (KeyValuePair <string, int> temp_data in supplier_and_quantity)
                {
                    item_ware_obj.stock_balance = item_ware_obj.stock_balance + temp_data.Value;
                    suppliers sup_obj = db.suppliers_repository.Where(s => s.name == temp_data.Key).FirstOrDefault();

                    if (temp_data.Key == "OUT_OF_STOCK_IN_SUPPLIER")
                    {
                        supplier_status = "OUT_OF_STOCK_IN_SUPPLIER";
                    }
                    else if (sup_obj.suppliersId == 1)
                    {
                        item_ware_obj.first_supplier_balance = item_ware_obj.first_supplier_balance + temp_data.Value;
                        db.SaveChanges();

                        // STOCK CARD UPDATE
                        stock_card stock_card_obj = new stock_card(sup_obj.name, DateTime.Now.ToString(), "+ " + temp_data.Value, item_ware_obj.item);
                        db.stock_card_repository.Add(stock_card_obj);
                        db.SaveChanges();
                    }
                    else if (sup_obj.suppliersId == 2)
                    {
                        item_ware_obj.second_supplier_balance = item_ware_obj.second_supplier_balance + temp_data.Value;
                        db.SaveChanges();

                        // STOCK CARD UPDATE
                        stock_card stock_card_obj = new stock_card(sup_obj.name, DateTime.Now.ToString(), "+ " + temp_data.Value, item_ware_obj.item);
                        db.stock_card_repository.Add(stock_card_obj);
                        db.SaveChanges();
                    }
                    else if (sup_obj.suppliersId == 3)
                    {
                        item_ware_obj.third_supplier_balance = item_ware_obj.third_supplier_balance + temp_data.Value;
                        db.SaveChanges();

                        // STOCK CARD UPDATE
                        stock_card stock_card_obj = new stock_card(sup_obj.name, DateTime.Now.ToString(), "+ " + temp_data.Value, item_ware_obj.item);
                        db.stock_card_repository.Add(stock_card_obj);
                        db.SaveChanges();
                    }
                }
            }
            object reply_to_client = new
            {
                supplier_and_quantity_key    = supplier_and_quantity,
                supplier_out_of_stock_status = supplier_status,
            };

            return(Json(reply_to_client, JsonRequestBehavior.AllowGet));
        }
        protected override void Seed(DataBaseContext context)
        {
            // ITEM INITIALIZATION
            string[] item_code         = new string[] { "C001", "C002", "C003", "E001", "E002", "E003", "F020", "F021", "F022", "H011", "H012", "H013", "P010", "P011", "P012", "R002", "R001", "S100", "S040", "S101", "T001", "T002", "T003" };
            string[] category          = new string[] { "Clip", "Clip", "Clip", "Envelope", "Envelope", "Envelope", "File", "File", "File", "Pen", "Pen", "Pen", "Pad", "Pad", "Pad", "Ruler", "Ruler", "Scissors", "Tape", "Tape", "Tracks", "Tacks", "Tacks" };
            string[] description       = new string[] { "Clips Double 1\"", "Clips Double 2\"", "Clips Double 3/4 \"", "Envelope Brown 3*6", "Envelope Brown 4*7", "Envelope Brown 5*7", "File Separator", "File-Blue Plain", "File-Blue with Logo", "Highlighter Blue", "Highlighter Green", "Highlighter Pink", "Hole Puncher 2 holes", "Hole Puncher 3 holes", "Hole Puncher Adjustable", "Ruler 12\"", "Ruler 6\"", "Scissors", "Scotch Tape", "Scotch Tape Dispenser", "Thumb Tacks Large", "Thumb Tacks Medium", "Thumb Tacks Small" };
            Random   unit_price_random = new Random();

            List <item> item_list = new List <item>();

            for (int i = 0; i < item_code.Length; i++)
            {
                item item_obj = new item();
                item_obj.item_code        = item_code[i];
                item_obj.item_description = description[i];
                item_obj.category         = category[i];
                item_obj.unit_price       = unit_price_random.Next(1, 20);
                item_list.Add(item_obj);

                context.item_repository.Add(item_obj);
                context.SaveChanges();
            }

            // SUPPLIER INITIALIZATION
            string[]         supplier_code = new string[] { "ALPA", "CHEP", "BANE", "OMEG" };
            string[]         supplier_name = new string[] { "ALPHA Office Supplies", "Cheap Stationer", "BANE SHOP", "OMEGA Stationery Supplier" };
            string[]         contact_name  = new string[] { "Ms Irene Tan", "Mr Soh Kway Koh", "Mr Loh Ah Pek", "Mr Ronnie Ho" };
            int[]            phone_no      = new int[] { 46119928, 3543234, 4781234, 7671233 };
            int[]            fax           = new int[] { 4612238, 4742434, 4792434, 7671234 };
            string[]         address       = new string[] { " Blk 1128, Ang Mo Kio Industrial Park,#02-1108 Ang Mo Kio Street 62,Singapore 622262", "Blk 34, Clementi Road,#07-02 Ban Ban Soh Building,Singapore 110525", " Blk 124, Alexandra Road,#03-04 Banes Building,Singapore 550315", "Blk 11, Hillview Avenue,#03-04,Singapore 679036" };
            List <suppliers> suppliers_lis = new List <suppliers>();

            for (int i = 0; i < supplier_code.Length; i++)
            {
                suppliers supplier_obj = new suppliers(supplier_code[i], supplier_name[i], contact_name[i], fax[i], address[i], phone_no[i]);
                suppliers_lis.Add(supplier_obj);

                context.suppliers_repository.Add(supplier_obj);
                context.SaveChanges();
            }

            // SUPPLIER WAREHOUSE
            // WAREHOUSE For FIRST SUPPLIER
            int[] quantity_item = new int[] { 50, 100, 75, 55, 125, 400, 500, 300, 100, 200, 800, 900, 700, 230, 840, 120, 320, 410, 470, 340, 320, 160, 750 };
            int[] price         = new int[] { 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };
            int[] item_id       = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 };

            suppliers first_supplier_obj = new suppliers();
            List <suppliers_warehouse> suppliers_warehouse_lis = new List <suppliers_warehouse>();

            for (int k = 0; k < 3; k++)
            {
                for (int i = 0; i < item_code.Length; i++)
                {
                    item      item_obj     = (item)item_list[i];
                    suppliers supplier_obj = (suppliers)suppliers_lis[k];

                    suppliers_warehouse supplier_ware_obj = new suppliers_warehouse(quantity_item[i], quantity_item[i], price[i]);

                    supplier_ware_obj.suppliers_warehouse_plus_item     = item_obj;
                    supplier_ware_obj.suppliers_warehouse_plus_supplier = supplier_obj;

                    suppliers_warehouse_lis.Add(supplier_ware_obj);

                    context.suppliers_warehouse_repository.Add(supplier_ware_obj);
                    context.SaveChanges();
                }
            }

            // DEPARTMENT Initialization
            string[]          depart_code              = new string[] { "ENGL", "CPSC", "Stationery Store Inventory System", "REGR", "ZOOL" };
            string[]          depart_name              = new string[] { "English Dept", "Computer Science", "Commerce Dept", "Registrar Dept", "Zoology Dept" };
            string[]          dept_contact_name        = new string[] { "Mrs Pamela Kow", "Mr Wee Kian Fatt", "Mr Mohd. Azman", "Ms Helen Ho", "Mr. Peter Tan Ah Meng" };
            int[]             dept_tel_no              = new int[] { 8742234, 8901235, 8741284, 8901266, 8901266 };
            int[]             dept_fax_no              = new int[] { 8921456, 8921457, 8921256, 8921465, 8921465 };
            string[]          dept_head_name           = new string[] { "Prof Ezra Pound", "Dr. Soh Kian Wee", "Dr. Chia Leow Bee", "Mrs Low Kway Boo", "Prof Tan" };
            string[]          collection_point_list    = new string[] { "Stationery Store", "Managament School", "Medical School", "Engineering School", "Science School", "University Hospital" };
            string[]          representative_name_list = new string[] { "KayKay", "KyawKyaw", "AungAung", "TinTin", "NawNaw" };
            List <department> depart_lis = new List <department>();

            for (int i = 0; i < depart_code.Length; i++)
            {
                department dept_obj = new department(depart_code[i], depart_name[i], dept_contact_name[i], dept_tel_no[i], dept_fax_no[i], dept_head_name[i], collection_point_list[i], representative_name_list[i]);

                depart_lis.Add(dept_obj);

                context.department_repository.Add(dept_obj);
                context.SaveChanges();
            }

            // STAFF Initialization
            List <staff> staff_lis = new List <staff>();
            // EMPLOYEE INITIALIZATION
            // First Department
            staff staff_obj = new staff("KayKay", "*****@*****.**", "kay1234", 21, "male", "Employee", depart_lis[0]);

            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            staff_obj = new staff("NayNay", "*****@*****.**", "nay1234", 27, "female", "Employee", depart_lis[0]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            staff_obj = new staff("ZawZaw", "*****@*****.**", "zaw1234", 32, "male", "Employee", depart_lis[0]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            // Second Department
            staff_obj = new staff("KyawKyaw", "*****@*****.**", "kyaw1234", 21, "male", "Employee", depart_lis[1]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            staff_obj = new staff("MgMg", "*****@*****.**", "mg1234", 22, "male", "Employee", depart_lis[1]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            // Third Department
            staff_obj = new staff("AungAung", "*****@*****.**", "aung1234", 21, "male", "Employee", depart_lis[2]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            staff_obj = new staff("HtikeHtike", "*****@*****.**", "htike1234", 22, "female", "Employee", depart_lis[2]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            // Fourth Department
            staff_obj = new staff("TinTin", "*****@*****.**", "tin1234", 24, "male", "Employee", depart_lis[3]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            staff_obj = new staff("MyintMyint", "*****@*****.**", "myint1234", 22, "female", "Employee", depart_lis[3]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            // Fifth Department
            staff_obj = new staff("NawNaw", "*****@*****.**", "naw1234", 25, "male", "Employee", depart_lis[4]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            staff_obj = new staff("MawMaw", "*****@*****.**", "maw1234", 29, "female", "Employee", depart_lis[4]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            // HEAD INITIALIZATION
            staff_obj = new staff("HtetMoeHlyan", "*****@*****.**", "htet1234", 22, "male", "Head", depart_lis[0]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            staff_obj = new staff("KaungPyaeHtet", "*****@*****.**", "kaung1234", 24, "male", "Head", depart_lis[1]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            staff_obj = new staff("MyintThein", "*****@*****.**", "myint1234", 22, "female", "Head", depart_lis[2]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            staff_obj = new staff("ChoChoMaw", "*****@*****.**", "cho1234", 25, "female", "Head", depart_lis[3]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            staff_obj = new staff("MayThin", "*****@*****.**", "may1234", 29, "female", "Head", depart_lis[4]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();
            // SUPERVISOR INITIALIZATION
            staff_obj = new staff("YeeMonAung", "*****@*****.**", "yee1234", 22, "female", "Supervisor", depart_lis[2]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();

            /*
             * staff_obj = new staff("YanMueAung", "*****@*****.**", "htet1234", 22, "male", "Supervisor", depart_lis[0]);
             * staff_lis.Add(staff_obj);
             * context.staff_repository.Add(staff_obj);
             * context.SaveChanges();
             * staff_obj = new staff("KaungKhantKyaw", "*****@*****.**", "khant1234", 24, "male", "Supervisor", depart_lis[1]);
             * staff_lis.Add(staff_obj);
             * context.staff_repository.Add(staff_obj);
             * context.SaveChanges();
             * staff_obj = new staff("KhaingSuWai", "*****@*****.**", "khaing1234", 25, "female", "Supervisor", depart_lis[3]);
             * staff_lis.Add(staff_obj);
             * context.staff_repository.Add(staff_obj);
             * context.SaveChanges();
             * staff_obj = new staff("PhyuPhyuThein", "*****@*****.**", "phyu1234", 29, "female", "Supervisor", depart_lis[4]);
             * staff_lis.Add(staff_obj);
             * context.staff_repository.Add(staff_obj);
             * context.SaveChanges();
             */
            // MANAGER INITIALIZATION
            staff_obj = new staff("NuNu", "*****@*****.**", "nu1234", 61, "female", "Manager", depart_lis[2]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();

            // CLERK INITIALIZATION
            staff_obj = new staff("AyeMoePhyu", "*****@*****.**", "amp1234", 29, "female", "Clerk", depart_lis[4]);
            staff_lis.Add(staff_obj);
            context.staff_repository.Add(staff_obj);
            context.SaveChanges();

            // STAFF REPRESENTATIVE

            // ORDER ITEM Initialization
            Random rand = new Random();

            int[]         staff_member         = new int[] { 0, 3, 5, 9, 10 };
            int[]         specific_item_number = new int[] { 2, 5, 1, 4, 6, 8, 9, 13, 16, 20 };
            List <orders> order_item_lis       = new List <orders>();

            for (int k = 0; k < staff_member.Length; k++)
            {
                staff temp_staff = staff_lis[staff_member[k]];

                for (int j = 0; j < specific_item_number.Length; j++)
                {
                    item temp_item = item_list[j];

                    orders temp_order_item_obj = new orders(temp_staff, temp_item, rand.Next(20, 100), DateTime.Now.ToString());

                    order_item_lis.Add(temp_order_item_obj);

                    context.orders_repository.Add(temp_order_item_obj);

                    context.SaveChanges();
                }
            }

            // ITEM WAREHOUSE Initialization
            int    reorder_level    = 5;
            int    reorder_quantity = 10;
            string unit_of_measure  = "each";

            using (var db = new DataBaseContext())
            {
                // ALL DATA
                List <suppliers_warehouse> sup_ware_lis = db.suppliers_warehouse_repository.Where(x => x.suppliers_warehouse_plus_supplier.suppliersId == 1).Select(x => x).ToList();
                for (int i = 0; i < sup_ware_lis.Count; i++)
                {
                    //TARGET DATA
                    suppliers_warehouse sup_ware = sup_ware_lis[i];

                    //ITEM SPECIFIC
                    item specific_item_obj = db.item_repository.Where(x => x.itemId == sup_ware.suppliers_warehouse_plus_item.itemId).Select(x => x).FirstOrDefault();
                    int  sup_balance       = sup_ware.stock_balance;

                    if (sup_balance > reorder_level)
                    {
                        sup_balance = sup_balance - reorder_quantity;
                        items_warehouse item_ware = new items_warehouse(reorder_level, reorder_quantity, unit_of_measure, reorder_quantity, reorder_quantity, 0, 0, specific_item_obj);

                        // SUPPLIER WAREHOUSE
                        suppliers_warehouse db_sup_ware = db.suppliers_warehouse_repository.Where(x => x.suppliers_warehouseId == sup_ware.suppliers_warehouseId).FirstOrDefault();
                        db_sup_ware.stock_balance = sup_balance;

                        // STOCK CARD INITIALIZATION
                        stock_card stock_card_obj = new stock_card(db_sup_ware.suppliers_warehouse_plus_supplier.name, DateTime.Now.ToString(), "+" + reorder_quantity, specific_item_obj);
                        db.stock_card_repository.Add(stock_card_obj);
                        db.SaveChanges();

                        db.item_warehouses_repository.Add(item_ware);
                        db.SaveChanges();
                        db.suppliers_warehouse_repository.Add(db_sup_ware);
                        db.SaveChanges();
                    }
                }
            }

            base.Seed(context);
        }
Ejemplo n.º 22
0
 private void PutProductSupplierData(suppliers prosup)
 {
     prosup.ProductId  = Convert.ToInt32(txtProductID.Text);
     prosup.SupplierId = Convert.ToInt32(txtSupplierID.Text);
 }
Ejemplo n.º 23
0
 public void AddSupplier(suppliers supplier)
 {
     suppliers.Add(supplier);
 }