public static void setProduct(int waybill_no, int barcode,
                                      int supplier_no, int product_no,
                                      float unit_input_price, int amount,
                                      float price, DateTime debt_date,
                                      string product_name)
        {
            if (getProductbyBarcode(barcode) == null)
            {             //eklenecek ürünün database de olup olmadığınıa bakılır.
                Supplier sup = Supplier.setSupplier(supplier_no);

                using (MngContext context = new MngContext())
                {
                    Product p = new Product
                    {
                        waybill_no       = waybill_no,
                        barcode          = barcode,
                        supplier_no      = supplier_no,
                        product_no       = product_no,
                        unit_input_price = unit_input_price,
                        amount           = amount,
                        price            = price,
                        product_name     = product_name,
                        Supplier         = sup,
                        MarketDebt       = MarketDebt.setMDebt(price, debt_date, barcode),
                    };

                    context.Products.Add(p);
                    context.SaveChanges();
                }
            }
        }
        public static void setDSale(int customer_no, int sale_no, int product_no, float unit_input_price,
                                    DateTime sale_date, string payment_method,
                                    string empusname, int barcode, float price)
        {
            using (MngContext context = new MngContext())
            {
                Employee e = Employee.getEmployeebyUsName(empusname);

                DebitSale m = new DebitSale
                {
                    customer_no      = customer_no,
                    sale_no          = sale_no,
                    price            = price,
                    unit_input_price = unit_input_price,
                    product_no       = product_no,
                    sale_date        = sale_date,
                    payment_method   = payment_method,
                    barcode          = barcode,
                    Employee         = e,
                };
                m.CustomerDebt = CustomerDebt.setCDebt(customer_no, price, sale_date, sale_no);

                context.DebitSales.Add(m);
                context.SaveChanges();
            }
        }
        public static Product getProductbyBarcode(int barcode)
        {
            Product productInfo;

            using (MngContext context = new MngContext()){
                productInfo = context.Products.SqlQuery("Select * from Products where barcode=@bcd", new SqlParameter("@bcd", barcode)).FirstOrDefault <Product>();
            }

            return(productInfo);
        }
Exemple #4
0
        public static Employee getEmployee(string dusername, string dpassword)
        {
            Employee employeeInfo;

            using (var context = new MngContext()) {
                employeeInfo = context.Employees.SqlQuery("Select emp_no, username, password from Employees where username=@usr and password=@pwd", new SqlParameter("@usr", dusername), new SqlParameter("@pwd", dpassword)).FirstOrDefault <Employee>();
            }

            return(employeeInfo);
        }
Exemple #5
0
        public static CustomerDebt getCDebt(int sale_no)
        {
            CustomerDebt cDebtInfo;

            using (MngContext context = new MngContext())
            {
                cDebtInfo = context.CustomerDebts.SqlQuery("Select * from CustomerDebts where sale_no=@cno", new SqlParameter("@cno", sale_no)).FirstOrDefault <CustomerDebt>();
            }

            return(cDebtInfo);
        }
Exemple #6
0
        public static List <MarketDebt> getMDebtnonPayed()
        {         //toplam market borcu
            List <MarketDebt> debtInfo;

            using (MngContext context = new MngContext())
            {
                debtInfo = context.MarketDebts.SqlQuery("Select * from MarketDebts where payed=false").ToList();
            }

            return(debtInfo);
        }
        public static List <Product> getAllProduct()
        {         //toplam market borcu
            List <Product> ProductInfo;

            using (MngContext context = new MngContext())
            {
                ProductInfo = context.Products.SqlQuery("Select * from Products").ToList();
            }

            return(ProductInfo);
        }
        public static Product getProductbyProductNo(int product_no)
        {
            Product productInfo;

            using (MngContext context = new MngContext())
            {
                productInfo = context.Products.SqlQuery("Select * from Products where product_no=@pdcno", new SqlParameter("@pdcno", product_no)).FirstOrDefault <Product>();
            }

            return(productInfo);
        }
        public static Supplier getSupplier(int supplier_no)
        {
            Supplier supplierInfo;

            using (MngContext context = new MngContext())
            {
                supplierInfo = context.Suppliers.SqlQuery("Select * from Suppliers where supplier_no=@sno", new SqlParameter("@sno", supplier_no)).FirstOrDefault <Supplier>();
            }

            return(supplierInfo);
        }
        public static List <DebitSale> getallDSale()
        {
            List <DebitSale> dSaleInfo;

            using (var context = new MngContext())
            {
                dSaleInfo = context.DebitSales.SqlQuery("Select * from DebitSales").ToList();
            }

            return(dSaleInfo);
        }
        public static DebitSale getDebitSale(int customer_no)
        {
            DebitSale debitInfo;

            using (var context = new MngContext())
            {
                debitInfo = context.DebitSales.SqlQuery("Select * from DebitSales where customer_no=@cno", new SqlParameter("@cno", customer_no)).FirstOrDefault <DebitSale>();
            }

            return(debitInfo);
        }
        public static void delProductByBarcode(int barcode)
        {
            Product del_product = getProductbyBarcode(barcode);

            if (del_product != null)
            {
                using (MngContext context = new MngContext())
                {
                    context.Products.Attach(del_product);
                    context.Products.Remove(del_product);
                    context.SaveChanges();
                }
            }
        }
Exemple #13
0
        public static void setEmployee(string dusername, string dpassword)
        {
            if (getEmployee(dusername, dpassword) == null)
            {             //eklenecek çalışanın database de olup olmadığınıa bakılır.
                using (var context = new MngContext())
                {
                    Employee e = new Employee
                    {
                        username = dusername,
                        password = dpassword,
                    };

                    context.Employees.Add(e);
                    context.SaveChanges();
                }
            }
        }
        public static Supplier setSupplier(int supplier_no)
        {
            if (getSupplier(supplier_no) == null)
            {             //eklenecek firmanın database de olup olmadığınıa bakılır.
                using (var context = new MngContext())
                {
                    Supplier e = new Supplier
                    {
                        supplier_no = supplier_no,
                    };

                    context.Suppliers.Add(e);
                    context.SaveChanges();

                    return(e);
                }
            }
            return(null);
        }
Exemple #15
0
        public static CustomerDebt setCDebt(int customer_no, float debt_amount,
                                            DateTime debt_date, int sale_no)
        {
            using (MngContext context = new MngContext())
            {
                CustomerDebt m = new CustomerDebt
                {
                    sale_no     = sale_no,
                    customer_no = customer_no,
                    debt_amount = debt_amount,
                    debt_date   = debt_date,
                    payed       = false,               //ürün stoğa eklendiğinde borç oluşur daima
                };

                context.CustomerDebts.Add(m);
                context.SaveChanges();

                return(m);
            }
        }
Exemple #16
0
        public static MarketDebt setMDebt(float debt_amount,
                                          DateTime debt_date,
                                          int barcode)
        {
            using (MngContext context = new MngContext())
            {
                MarketDebt m = new MarketDebt
                {
                    debt_amount = debt_amount,
                    debt_date   = debt_date,
                    barcode     = barcode,
                    payed       = false,               //ürün stoğa eklendiğinde borç oluşur daima
                };

                context.MarketDebts.Add(m);
                context.SaveChanges();

                return(m);
            }
        }