示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string query = "select count(*) from admins where Username='******'  and  Password='******' and Position='" + position.Text + "'";
                con.Open();
                cmd             = con.CreateCommand();
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = query;

                int x = Convert.ToInt32(cmd.ExecuteScalar());
                con.Close();

                if (x == 1)
                {
                    if (position.Text == "Sales Manager")
                    {
                        SalesSub s1 = new SalesSub(textBox1.Text);
                        s1.Show();
                        this.Hide();
                    }
                    else if (position.Text == "HR Manager")
                    {
                        HarasaraSystem.SubInterface.Employee.EmployeeSub e1 = new HarasaraSystem.SubInterface.Employee.EmployeeSub(textBox1.Text);
                        e1.Show();
                        this.Hide();
                    }
                    else if (position.Text == "Adminstration")
                    {
                        HarasaraSystem.SubInterface.Administration.AdministrationSub a1 = new SubInterface.Administration.AdministrationSub(textBox1.Text);
                        a1.Show();
                        this.Hide();
                    }
                    else if (position.Text == "Finance")
                    {
                        HarasaraSystem.SubInterface.Finance.FinanceSub f1 = new SubInterface.Finance.FinanceSub(textBox1.Text);
                        f1.Show();
                        this.Hide();
                    }
                    else if (position.Text == "Products")
                    {
                        HarasaraSystem.SubInterface.Production.ProductionSub p1 = new SubInterface.Production.ProductionSub(textBox1.Text);
                        p1.Show();
                        this.Hide();
                    }
                    else if (position.Text == "Inventory")
                    {
                        HarasaraSystem.SubInterface.Inventory.InventorySub i1 = new SubInterface.Inventory.InventorySub(textBox1.Text);
                        i1.Show();
                        this.Hide();
                    }

                    else
                    {
                            << << << < HEAD
                            Transport.Main t1 = new Transport.Main();
        public async Task <ActionResult <SalesMain> > PostSalesMain(SalesMain salesMain)
        {
            try
            {   //Sales Main Table
                if (salesMain.SalesMainID == 0)
                {
                    _context.SalesMains.Add(salesMain);
                }
                else
                {
                    _context.Entry(salesMain).State = EntityState.Modified;

                    //Sales Subs Table

                    foreach (var item in salesMain.SalesItems)
                    {
                        if (item.SalesSubID == 0)
                        {
                            _context.SalesSubs.Add(item);
                        }
                        else
                        {
                            _context.Entry(item).State = EntityState.Modified;
                        }
                    }
                }



                //Delete SalesSub TableItems
                if (salesMain.DeletedOrderItemIDs != null)
                {
                    foreach (var id in salesMain.DeletedOrderItemIDs)
                    {
                        SalesSub sales = _context.SalesSubs.FirstOrDefault(x => x.SalesSubID == id);
                        _context.SalesSubs.Remove(sales);
                    }
                }

                await _context.SaveChangesAsync();

                return(Ok());
            }
            catch (Exception ex)
            {
                throw ex;
            }


            //return CreatedAtAction("GetSalesMain", new { id = salesMain.SalesMainID }, salesMain);
        }