예제 #1
0
        protected void loadgrid()
        {
            if (fdpTxt.Text != "")
            {
                int tempBranchId = Convert.ToInt32(PMDropdownlist.SelectedItem.Value);
                // string fdt = datepicker.Text;
                //string tdt = datepicker1.Text;
                DateTime tdt;
                if (tdpTxt.Text != "")
                {
                    tdt = DateTime.Parse(tdpTxt.Text);
                }
                else
                {
                    tdt = System.DateTime.Now;
                }

                DateTime fdt = DateTime.Parse(fdpTxt.Text);


                try
                {
                    using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                    {
                        var excludeStock = dbobj.sp_Search_Exclude(tempBranchId, fdt, tdt).ToList();

                        GridView1.DataSource = excludeStock;
                        GridView1.DataBind();
                    }
                }
                catch (Exception)
                {
                }
            }
        }
        protected void Button7_Click(object sender, EventArgs e)
        {
            DateTime tdt;
            if (datepicker.Text != "")
            {

                if (datepicker1.Text != "")
                {
                    tdt = DateTime.Parse(datepicker1.Text);
                }
                else
                {
                    tdt = System.DateTime.Now;
                }
                DateTime fdt = DateTime.Parse(datepicker.Text);

                try
                {
                    using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities()) 
                    {
                        var wdReport = dbobj.sp_withdraw_report(fdt, tdt).ToList();

                        GridView2.DataSource = wdReport;
                        GridView2.DataBind();
                    }
                }
                catch (Exception)
                {
                }
            }
        }
예제 #3
0
        protected void PMDropdownlist_SelectedIndexChanged(object sender, EventArgs e)
        {
            int locId = Convert.ToInt32(PMDropdownlist.SelectedItem.Value);

            using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
            {
                IEnumerable <sp_finalStockList_Result> gsl = dbobj.sp_finalStockList(locId).ToList();

                GridView2.DataSource = gsl;
                GridView2.DataBind();

                locId = Convert.ToInt32(PMDropdownlist.SelectedItem.Value);


                ProductList.Items.Clear();
                ExProdList.Items.Clear();

                var prod = dbobj.sp_finalStockList(locId).ToList();

                ProductList.DataSource = prod;
                ProductList.DataBind();
                ProductList.Items.Insert(0, new ListItem("Select Product", ""));


                ExProdList.DataSource = prod;
                ExProdList.DataBind();
                ExProdList.Items.Insert(0, new ListItem("Select Product", ""));
            }
        }
예제 #4
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            using (AdvInvSystemEntities comp = new AdvInvSystemEntities())
            {
                var folder = Server.MapPath("~/Images/company/");
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }


                if (FileUpload1.FileName != "")
                {
                    string dgImg = Server.MapPath(@"Images/company/" + FileUpload1.FileName);
                    FileUpload1.SaveAs(dgImg);
                }
                Brand bd = new Brand();

                bd.CompanyName   = compNm.Text;
                bd.ContactPerson = compPers.Text;
                bd.ContactNumber = cellNm.Text;
                bd.Logo          = "images/company/" + FileUpload1.FileName;

                comp.Brands.Add(bd);
                comp.SaveChanges();

                compNm.Text   = "";
                compPers.Text = "";
                cellNm.Text   = "";
            }
            Button2.Enabled = false;

            Response.Redirect(Request.RawUrl);
        }
        protected void Button8_Click(object sender, EventArgs e)
        {
            DateTime tdt;
            if (dp3.Text != "")
            {

                if (dp4.Text != "")
                {
                    tdt = DateTime.Parse(dp4.Text);
                }
                else
                {
                    tdt = System.DateTime.Now;
                }
                DateTime fdt = DateTime.Parse(dp3.Text);

                try
                {
                    using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                    {
                        var fundTrns = dbobj.sp_Add_fund(fdt, tdt).ToList();

                        GridView4.DataSource = fundTrns;
                        GridView4.DataBind();
                    }
                }
                catch (Exception)
                {
                }
            }
        }
        protected void PMDropdownlist_SelectedIndexChanged(object sender, EventArgs e)
        {
            chqTxt.Text = "";
            bnkTxt.Text = "";
            mbTxt.Text  = "";
            ammTxt.Text = "";

            AdvInvSystemEntities dbobj = new AdvInvSystemEntities();

            /*   if (acd.Type == "Cheque")
             * {
             *
             *     bk.Visible = true;
             *     paidTxt.Text = "";
             *     paidTxt.Enabled = false;
             * }
             * else
             * {
             *     bk.Visible = false;
             *     paidTxt.Enabled = true;
             * }
             *
             *
             *
             * if (acd.Type == "Cash")
             * {
             *     AccType = "InHand";
             * }
             * else if (acd.Type == "Cheque")
             * {
             *     AccType = "Bank";
             * }
             */
        }
예제 #7
0
        protected void spcellTxt_TextChanged(object sender, EventArgs e)
        {
            spnmTxt.Focus();
            using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
            {
                Supplier sp = new Supplier();

                sp = (from sup in dbobj.Suppliers
                      where sup.CellNumber == spcellTxt.Text
                      select sup).FirstOrDefault();

                if (sp != null)
                {
                    spnmTxt.Text  = sp.Name;
                    spcomTxt.Text = sp.Company;
                    spaddTxt.Text = sp.Address;
                }

                else
                {
                    spnmTxt.Text  = "";
                    spcomTxt.Text = "";
                    spaddTxt.Text = "";
                }
            }
        }
예제 #8
0
        protected void Search_Click(object sender, EventArgs e)
        {
            int tempBranchId = Convert.ToInt32(PMDropdownlist.SelectedItem.Value);
            // string fdt = datepicker.Text;
            //string tdt = datepicker1.Text;
            DateTime tdt;

            if (datepicker1.Text != "")
            {
                tdt = DateTime.Parse(datepicker1.Text);
            }
            else
            {
                tdt = System.DateTime.Now;
            }

            DateTime fdt = DateTime.Parse(datepicker.Text);

            try
            {
                using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                {
                    IEnumerable <sp_Search_Expense_Result> se = dbobj.sp_Search_Expense(tempBranchId, fdt, tdt);

                    GridView1.DataSource = se;
                    GridView1.DataBind();
                }
            }
            catch (Exception ex)
            {
            }
        }
예제 #9
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                {
                    Expense ex = new Expense();

                    ex.Particular = prtTxt.Text;
                    ex.Date       = System.DateTime.Now;
                    ex.Type       = DropDownList1.SelectedItem.Value;
                    ex.Amount     = Convert.ToInt32(amTxt.Text);
                    ex.AccountId  = Convert.ToInt32(DropDownList2.SelectedItem.Value);
                    ex.UserId     = Convert.ToInt32(Session["UserId"]);
                    ex.BranchId   = Convert.ToInt32(Session["BranchId"]);

                    dbobj.Expenses.Add(ex);
                    dbobj.SaveChanges();

                    ViewState["expId"] = ex.ExpenseId;

                    int tempAccId = Convert.ToInt32(DropDownList2.SelectedItem.Value);

                    Account ac = new Account();
                    ac = (from act in dbobj.Accounts
                          where act.AccountId == tempAccId
                          select act).FirstOrDefault();

                    if (ac != null)
                    {
                        int tempBal = Convert.ToInt32(ac.CurrentBalance);
                        int updBal  = tempBal - Convert.ToInt32(amTxt.Text);
                        ac.CurrentBalance = updBal.ToString();
                        dbobj.SaveChanges();
                    }

                    AccountDetail acd = new AccountDetail();

                    acd.Particular = "Pay Expense Id# " + ViewState["expId"];
                    acd.Amount     = Convert.ToInt32(amTxt.Text);
                    acd.Mode       = "Outward";
                    acd.DateTime   = System.DateTime.Now;
                    acd.AccountId  = tempAccId;
                    acd.UserId     = 1;
                    acd.Type       = "Cash";

                    dbobj.AccountDetails.Add(acd);
                    dbobj.SaveChanges();


                    myalert.Visible = true;

                    Response.Redirect(Request.RawUrl);
                }
            }
            catch (Exception)
            {
                myfailalert.Visible = true;
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (FileUpload1.FileName != "")
            {
                string dgImg = Server.MapPath(@"Images/avatar/" + FileUpload1.FileName);
                FileUpload1.SaveAs(dgImg);
            }
            using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
            {
                LoginUser lu = new LoginUser();
                lu = (from us1 in dbobj.LoginUsers
                      where us1.UserId == mytempId
                      select us1).FirstOrDefault();

                if (lu != null)
                {
                    lu.Name       = NmTxt.Text;
                    lu.Password   = PassTxt.Text;
                    lu.EmailId    = EmailTxt.Text;
                    lu.CellNumber = CellTxt.Text;

                    if (FileUpload1.FileName != "")
                    {
                        lu.Image = "images/avatar/" + FileUpload1.FileName;
                    }

                    dbobj.SaveChanges();
                    Response.Redirect("Default.aspx");
                }
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (invTxt.Text != "")
            {
                int tempSaleInvId = Convert.ToInt32(invTxt.Text);
                try
                {
                    using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                    {
                        SaleInvoice s = new SaleInvoice();
                        s = (from s1 in dbobj.SaleInvoices where s1.SaleInvoicId == tempSaleInvId select s1).FirstOrDefault();
                        var si = from si1 in dbobj.SaleInvoices where si1.SaleInvoicId == tempSaleInvId select si1;


                        GridView3.DataSource = si.ToList();
                        GridView3.DataBind();

                        Customer cu = new Customer();

                        cu = (from c in dbobj.Customers where c.CustomerId == s.CustomerId select c).FirstOrDefault();

                        if (cu != null)
                        {
                            cusDetLbl.Text = cu.CustomerName + " / " + cu.CellNumber;

                            cusDetLbl.Visible = true;
                            Button3.Visible   = true;
                        }
                    }
                }
                catch (Exception)
                {
                }
            }
        }
예제 #12
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            tempId = Convert.ToInt32(ViewState["tempId"]);
            using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
            {
                StockLocation sl = new StockLocation();
                sl = (from s in dbobj.StockLocations where s.StockLocId == tempId select s).FirstOrDefault();

                sl.Name          = NmTxt.Text;
                sl.Location      = LocTxt.Text;
                sl.Supervisor    = SupTxt.Text;
                sl.ContactNumber = NumTxt.Text;

                dbobj.SaveChanges();
                NmTxt.Text  = "";
                LocTxt.Text = "";
                SupTxt.Text = "";
                NumTxt.Text = "";

                Button1.Enabled = true;
                Button2.Enabled = false;

                Response.Redirect("default.aspx");
            }
        }
예제 #13
0
        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "ImageClick") // check command is cmd_delete
            {
                Button2.Enabled = true;
                Button1.Enabled = false;

                // get you required value
                int brandId = Convert.ToInt32(e.CommandArgument);
                ViewState["bid"] = brandId;

                //Write some code for what you need


                try
                {
                    using (AdvInvSystemEntities comp = new AdvInvSystemEntities())
                    {
                        Brand bd = new Brand();
                        bd = (from b in comp.Brands where b.BrandId == brandId select b).FirstOrDefault();

                        compNm.Text   = bd.CompanyName;
                        compPers.Text = bd.ContactPerson;
                        cellNm.Text   = bd.ContactNumber;
                    }
                }
                catch (Exception)
                {
                }
            }
        }
예제 #14
0
        protected void PMDropdownlist_SelectedIndexChanged(object sender, EventArgs e)
        {
            chqTxt.Text = "";
            bnkTxt.Text = "";
            mbTxt.Text  = "";
            ammTxt.Text = "";

            AdvInvSystemEntities dbobj = new AdvInvSystemEntities();

            if (PMDropdownlist.SelectedItem.Value == "Cheque")
            {
                bk.Visible = true;
            }
            else
            {
                bk.Visible = false;
            }



            if (PMDropdownlist.SelectedItem.Text == "Cash")
            {
                AccType = "InHand";
            }
            else if (PMDropdownlist.SelectedItem.Text == "Cheque")
            {
                AccType = "Bank";
            }

            IEnumerable <sp_Accounts_type_Result> AT = dbobj.sp_Accounts_type(AccType).ToList();

            AccDropDownlist.DataSource = AT;
            AccDropDownlist.DataBind();
        }
 public void loadGrid(int id)
 {
     using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
     {
         GridView2.DataSource = dbobj.sp_purchase_detail(id).ToList();
         GridView2.DataBind();
     }
 }
 public void loadGrid(int id)
 {
     using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
     {
         IEnumerable <sp_sale_detail_Result> sd = dbobj.sp_sale_detail(id);
         GridView2.DataSource = sd;
         GridView2.DataBind();
     }
 }
예제 #17
0
        protected void Search_Click(object sender, EventArgs e)
        {
            int      tempBranchId = Convert.ToInt32(PMDropdownlist.SelectedItem.Value);
            DateTime tdt;

            if (datepicker1.Text != "")
            {
                tdt = DateTime.Parse(datepicker1.Text);
            }
            else
            {
                tdt = System.DateTime.Now;
            }
            DateTime fdt = DateTime.Parse(datepicker.Text);

            try
            {
                using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                {
                    GridView1.DataSource = dbobj.sp_search_saleInvoices(tempBranchId, fdt, tdt).ToList();
                    GridView1.DataBind();

                    GridView2.DataSource = dbobj.sp_search_purchaseInvoices(tempBranchId, fdt, tdt).ToList();
                    GridView2.DataBind();

                    GridView3.DataSource = dbobj.sp_Search_Expense(tempBranchId, fdt, tdt).ToList();
                    GridView3.DataBind();
                }

                int tempSaleAm = 0;
                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    tempSaleAm += Convert.ToInt32(GridView1.Rows[i].Cells[3].Text);
                }
                saleTxt.Text = tempSaleAm.ToString();


                int tempPurcAm = 0;
                for (int i = 0; i < GridView2.Rows.Count; i++)
                {
                    tempPurcAm += Convert.ToInt32(GridView2.Rows[i].Cells[3].Text);
                }
                purchTxt.Text = tempPurcAm.ToString();

                int tempExpAm = 0;
                for (int i = 0; i < GridView3.Rows.Count; i++)
                {
                    tempExpAm += Convert.ToInt32(GridView3.Rows[i].Cells[4].Text);
                }
                ExpTxt.Text = tempExpAm.ToString();
            }
            catch (Exception ex)
            {
            }
        }
        protected void Button5_Click(object sender, EventArgs e)
        {
            int tempAccId = Convert.ToInt32(WDAccDropDownList.SelectedItem.Value);
            Button5.Enabled = false;
            try
            {
                using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                {
                    var ac = (from a in dbobj.Accounts where a.AccountId == tempAccId select a).FirstOrDefault();

                    ac.CurrentBalance = (Convert.ToInt32(ac.CurrentBalance) - Convert.ToInt32(wAmTxt.Text)).ToString();
                    dbobj.SaveChanges();

                    Withdraw wd = new Withdraw();
                    wd.Particular = wPartTxt.Text;
                    wd.Amount = Convert.ToInt32(wAmTxt.Text);
                    wd.BranchId = Convert.ToInt32(Session["BranchId"]);
                    wd.Date = System.DateTime.Now;

                    TimeZoneInfo tzi;
                    DateTime dtTz;
                    tzi = TimeZoneInfo.FindSystemTimeZoneById("Pakistan Standard Time");
                    dtTz = TimeZoneInfo.ConvertTime(DateTime.Now, tzi);

                    wd.Time = dtTz.ToString("h:mm:ss tt");

                    wd.AccountId = tempAccId;
                    wd.UserId = Convert.ToInt32(Session["UserId"]);
                   
                    dbobj.Withdraws.Add(wd);
                    dbobj.SaveChanges();


                    AccountDetail ad = new AccountDetail();
                    ad.Particular = wPartTxt.Text + "Owner Withdraw";
                    ad.Amount = Convert.ToInt32(wAmTxt.Text);
                    ad.Mode = "Outward";
                    ad.DateTime = System.DateTime.Now;
                    ad.AccountId = tempAccId;
                    ad.UserId = Convert.ToInt32(Session["UserId"]);
                    ad.Type = "Cash";

                    dbobj.AccountDetails.Add(ad);
                    dbobj.SaveChanges();

                    Response.Redirect(Request.RawUrl);
                }
            }
            catch (Exception)
            {
            }
        }
예제 #19
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int id = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].Text);

            using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
            {
                var us = (from u in dbobj.LoginUsers where u.UserId == id select u).First();

                dbobj.LoginUsers.Remove(us);
                dbobj.SaveChanges();
            }
            Response.Redirect(Request.RawUrl);
        }
예제 #20
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            var folder = Server.MapPath("~/Images/avatar");

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }



            if (FileUpload1.FileName != "")
            {
                string dgImg = Server.MapPath(@"Images/avatar/" + FileUpload1.FileName);
                FileUpload1.SaveAs(dgImg);
            }

            using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
            {
                LoginUser lu = new LoginUser();

                lu.Name        = NmTxt.Text;
                lu.Password    = PassTxt.Text;
                lu.EmailId     = EmailTxt.Text;
                lu.Designation = DesTxt.Text;
                if (DropDownList1.SelectedItem.Value == "Active")
                {
                    lu.Status = 1;
                }
                else if (DropDownList1.SelectedItem.Value == "Deactive")
                {
                    lu.Status = 0;
                }
                lu.CellNumber = CellTxt.Text;
                if (FileUpload1.FileName != "")
                {
                    lu.Image = "images/avatar/" + FileUpload1.FileName;
                }

                lu.LocAssigned = Convert.ToInt32(DropDownList2.SelectedItem.Value);

                dbobj.LoginUsers.Add(lu);
                dbobj.SaveChanges();
            }


            Response.Redirect(Request.RawUrl);
        }
예제 #21
0
        protected void Button3_Click(object sender, EventArgs e)
        {
            var folder = Server.MapPath("~/Images/company/");

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }


            if (FileUpload2.FileName != "")
            {
                string dgImg = Server.MapPath(@"Images/products/" + FileUpload2.FileName);
                FileUpload2.SaveAs(dgImg);
            }
            int proId = Convert.ToInt32(DropDownList2.SelectedItem.Value);

            try
            {
                using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                {
                    var pd = (from p in dbobj.Products where p.ProductId == proId select p).FirstOrDefault();
                    if (pd != null)
                    {
                        pd.ProductName = eProNm.Text;
                        pd.Unit        = eunit.Text;
                        pd.Status      = estatus.Text;
                        pd.CompanyId   = Convert.ToInt32(DropDownList3.SelectedItem.Value);

                        if (FileUpload2.HasFile)
                        {
                            pd.img = "images/products/" + FileUpload2.FileName;
                        }

                        dbobj.SaveChanges();

                        eProNm.Text  = "";
                        eunit.Text   = "";
                        estatus.Text = "";
                        DropDownList3.SelectedIndex = 1;
                    }
                }
            }
            catch (Exception)
            {
            }
            Response.Redirect(Request.RawUrl);
        }
        protected void Search_Click(object sender, EventArgs e)
        {
            if (GridView2.Rows.Count >= 1)
            {
                GridView2.Visible    = false;
                DetailsView1.Visible = false;
            }
            GridView1.Visible = true;

            int tempBranchId = Convert.ToInt32(PMDropdownlist.SelectedItem.Value);
            // string fdt = datepicker.Text;
            //string tdt = datepicker1.Text;
            DateTime tdt;

            if (datepicker1.Text != "")
            {
                tdt = DateTime.Parse(datepicker1.Text);
            }
            else
            {
                tdt = System.DateTime.Now;
            }

            DateTime fdt = DateTime.Parse(datepicker.Text);

            try
            {
                using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                {
                    IEnumerable <sp_search_purchaseInvoices_Result> spi = dbobj.sp_search_purchaseInvoices(tempBranchId, fdt, tdt);

                    GridView1.DataSource = spi;
                    GridView1.DataBind();

                    int tempPurcAm = 0;
                    for (int i = 0; i < GridView1.Rows.Count; i++)
                    {
                        tempPurcAm += Convert.ToInt32(GridView1.Rows[i].Cells[4].Text);
                    }

                    tSale.Visible = true;
                    tSaleTxt.Text = tempPurcAm.ToString();
                }
            }
            catch (Exception ex)
            {
            }
        }
        protected void DDL_SelectedIndexChanged(object sender, EventArgs e)
        {
            qntyTxt.Focus();
            // ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Testing" + "');", true);
            qntyTxt.Enabled = true;
            discTxt.Text    = "0";
            Label1.Text     = "0";
            int prodid = Convert.ToInt32(DDL.SelectedItem.Value);

            using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
            {
                Product pd = new Product();

                pd = (from prod in dbobj.Products
                      where prod.ProductId == prodid
                      select prod).FirstOrDefault();

                priceTxt.Text = pd.SalePrice.ToString();

                ViewState["pp"] = priceTxt.Text;
                qntyTxt.Text    = "";
                //discTxt.Text = "";

                int   tempProId    = Convert.ToInt32(DDL.SelectedItem.Value);
                int   tempBranchId = Convert.ToInt32(Session["BranchId"]);
                Stock st           = new Stock();

                st = (from stk in dbobj.Stocks
                      where stk.ProductId == tempProId & stk.LocationId == tempBranchId
                      select stk).FirstOrDefault();
                if (st != null)
                {
                    availTxt.Text = st.Quantity + "";
                    int tempStock = Convert.ToInt32(st.Quantity);
                    ViewState["tempStock"] = tempStock;
                    if (tempStock == 0)
                    {
                        // qntyTxt.Enabled = false;               allow user to make -stock
                    }
                }
                else
                {
                    qntyTxt.Enabled = false;
                    availTxt.Text   = "";
                }
            }
        }
예제 #24
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
            {
                StockLocation sl = new StockLocation();

                sl.Name          = NmTxt.Text;
                sl.Location      = LocTxt.Text;
                sl.Supervisor    = SupTxt.Text;
                sl.ContactNumber = NumTxt.Text;

                dbobj.StockLocations.Add(sl);
                dbobj.SaveChanges();

                Response.Redirect(Request.RawUrl);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["sInvId"] != null)
            {
                id = (Int32)Session["sInvId"];
            }
            else
            {
                id = 69;
            }
            //

            try
            {
                using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                {
                    var si = dbobj.sp_saleInvoice_Dept(id).ToList();

                    userId = si[0].UserId;
                    shop   = si[0].Name;
                    dt     = si[0].Date.ToShortDateString();
                    ti     = si[0].Time;
                    gt     = (si[0].Amount + " /-").ToString();
                    dis    = (si[0].Discount + " /-").ToString();
                    pa     = (si[0].Payable + " /-").ToString();
                    pi     = (si[0].Paid + "/-").ToString();
                    invId  = si[0].SaleInvoicId;
                    cuName = si[0].CustomerName;

                    var pd = dbobj.sp_invoiceProduct_list(id).ToList();
                    GridView1.DataSource = pd;
                    GridView1.DataBind();

                    var si1 = (from s in dbobj.SaleInvoices where s.SaleInvoicId == id select s).FirstOrDefault();

                    int custId = si1.CustomerId;
                    var cus    = (from c in dbobj.Customers where c.CustomerId == custId select c).FirstOrDefault();

                    bal  = Convert.ToInt32(cus.Balance);
                    cell = cus.CellNumber;
                }
            }
            catch (Exception)
            {
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            mytempId = Convert.ToInt32(Session["UserId"]);
            if (!IsPostBack)
            {
                if (Session["UserEmail"] == null && Session["UserName"] == null)
                {
                    Response.Redirect("Login.aspx");
                }

                mytempId = Convert.ToInt32(Session["UserId"]);
                try
                {
                    using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                    {
                        LoginUser lu = new LoginUser();

                        lu = (from us1 in dbobj.LoginUsers
                              where us1.UserId == mytempId
                              select us1).FirstOrDefault();

                        if (lu != null)
                        {
                            imgUrl = lu.Image;
                            name   = lu.Name;
                            email  = lu.EmailId;
                            desig  = lu.Designation;
                            cell   = lu.CellNumber;
                            pass   = lu.Password;
                            status = lu.Status;

                            NmTxt.Text    = lu.Name;
                            EmailTxt.Text = lu.EmailId;
                            PassTxt.Text  = lu.Password;
                            CellTxt.Text  = lu.CellNumber;
                        }
                    }
                }
                catch (Exception ex)
                {
                    string err = ex.InnerException.Message;
                }
            }
            Page.DataBind();
        }
        protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            int     tempId = (Int32)ViewState["tempId"];
            Label   lpid   = (Label)GridView2.Rows[e.RowIndex].FindControl("pdId");
            int     id     = Convert.ToInt32(lpid.Text);
            TextBox qn     = (TextBox)GridView2.Rows[e.RowIndex].FindControl("qnty");
            TextBox rt     = (TextBox)GridView2.Rows[e.RowIndex].FindControl("pTxt");
            int     qnt    = Convert.ToInt32(qn.Text);

            qn.ReadOnly = false;
            rt.ReadOnly = false;
            try
            {
                using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                {
                    var pDetail = (from pd in dbobj.PurchaseDetails where pd.PurchaseDetailId == id select pd).FirstOrDefault();
                    var pInvoic = (from pi in dbobj.PurchaseInvoices where pi.PurchaseInvoiceId == tempId select pi).FirstOrDefault();
                    if (qnt == 0)
                    {
                        dbobj.PurchaseDetails.Remove(pDetail);
                        dbobj.SaveChanges();

                        pInvoic.Paid -= pDetail.Price;
                        dbobj.SaveChanges();
                    }
                    else if (qnt > 0)
                    {
                        pDetail.Quantity = qnt;
                        pDetail.Price    = Convert.ToInt32(rt.Text);

                        dbobj.SaveChanges();
                    }
                    GridView2.EditIndex = -1;

                    loadGrid(tempId);

                    DataBind();
                }

                Response.Redirect(Request.RawUrl);
            }
            catch (Exception)
            {
            }
        }
예제 #28
0
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            Button2.Enabled = true;
            Button1.Enabled = false;

            ViewState["tempId"] = Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text);
            tempId = Convert.ToInt32(ViewState["tempId"]);
            using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
            {
                StockLocation sl = new StockLocation();
                sl = (from s in dbobj.StockLocations where s.StockLocId == tempId select s).FirstOrDefault();

                NmTxt.Text  = sl.Name;
                LocTxt.Text = sl.Location;
                SupTxt.Text = sl.Supervisor;
                NumTxt.Text = sl.ContactNumber;
            }
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            if (AmTxt.Text != "")
            {
                Button1.Enabled = false;
                using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
                {
                    AddFund af = new AddFund();
                    af.Particular = PartTxt.Text;
                    af.Amount = Convert.ToInt32(AmTxt.Text);
                    af.AccountId = Convert.ToInt32(DropDownList1.SelectedItem.Value);
                    af.UserId = Convert.ToInt32(Session["UserId"]);
                    af.BranchId = Convert.ToInt32(Session["BranchId"]);
                    af.Date = System.DateTime.Now;
                    af.Time = DateTime.Now.ToString("h:mm:ss tt");

                    dbobj.AddFunds.Add(af);
                    dbobj.SaveChanges();

                    AccountDetail ad = new AccountDetail();
                    ad.Particular = PartTxt.Text;
                    ad.Amount = Convert.ToInt32(AmTxt.Text);
                    ad.Mode = "Inward";
                    ad.DateTime = System.DateTime.Now;
                    ad.UserId = Convert.ToInt32(Session["UserId"]);
                    ad.Type = "Cash";
                    ad.AccountId = Convert.ToInt32(DropDownList1.SelectedItem.Value);

                    dbobj.AccountDetails.Add(ad);
                    dbobj.SaveChanges();

                    var acc = (from a in dbobj.Accounts where a.AccountId == ad.AccountId select a).FirstOrDefault();

                    acc.CurrentBalance = (Convert.ToInt32(acc.CurrentBalance) + Convert.ToInt32(AmTxt.Text)).ToString();
                    dbobj.SaveChanges();
                }
                Response.Redirect(Request.RawUrl);
            }
            else
            {
                addFundError.Visible = true;
            }
        }
        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int tempId = Convert.ToInt32(GridView1.SelectedRow.Cells[1].Text);

            using (AdvInvSystemEntities dbobj = new AdvInvSystemEntities())
            {
                // IEnumerable<sp_purchaseInvoice_Depth_Result> pid = dbobj.sp_purchaseInvoice_Depth(tempId);

                DetailsView1.DataSource = dbobj.sp_purchaseInvoice_Depth(tempId).ToList();
                DetailsView1.DataBind();

                // IEnumerable<sp_purchase_detail_Result> pd = dbobj.sp_purchase_detail(tempId);
                loadGrid(tempId);
                GridView2.Visible    = true;
                DetailsView1.Visible = true;
            }

            GridView1.Visible = false;
        }