public int createPurchaseOrder(purchaseorder r)
 {
     try
     {
         purchaseorder req = new purchaseorder();
         req.POSuppID = r.POSuppID;
         req.POEmpID = r.POEmpID;
         req.POReqDate = r.POReqDate;
         req.PODeliverAddress = r.PODeliverAddress;
         req.POReqDeliverDate = r.POReqDeliverDate;
         cntx.purchaseorders.Add(req);
         cntx.SaveChanges();
         int id = req.POID;
         return id;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if ((HttpContext.Current.User.IsInRole("Store Manager") || HttpContext.Current.User.IsInRole("Store Supervisor") || HttpContext.Current.User.IsInRole("Store Clerk")) != true)
            {

                Response.Redirect("/Presentation/Login.aspx");

            }

            if (!IsPostBack)
            {
                int p;
                int.TryParse(Request.QueryString["POID"],out p);
                po = service.getPurchaseOrderByPOID(p);

                lblsname.Text=po.supplier.SupplierName;
                lblrename.Text=po.storeemp.StoreEmpName;
                lblRDate.Text=po.POReqDate.ToShortDateString();

                if (po.PODeliverAddress == null)
                {
                    lbladdress.Text = "Still Pending...";
                }
                else
                {
                    lbladdress.Text = po.PODeliverAddress;
                }

                if (po.POReqDeliverDate == null)
                {
                    lblrddate.Text = "Still Pending...";
                }
                else
                {
                    lblrddate.Text = po.POReqDeliverDate.ToShortDateString();
                }

                if (po.PORecieveDate == null)
                {
                    lblrecdate.Text = "Still Pending...";
                    //btnConfirm.Visible = true;
                }
                else
                {
                    lblrecdate.Text = po.PORecieveDate.ToString();
                    //btnConfirm.Visible = false;
                }
                binding();

                if (po.PORecieveDate == null)
                {
                    btnConfirm.Visible = true;
                }
                else
                {
                    btnConfirm.Visible = false;
                }

                //detail = service.getAllPurchaseOrderDetailStatusByPOID(p);
                //foreach (purchaseorderdetail dd in detail)
                //{

                    //if (dd.POStatus == "pending")
                    //{
                    //    btnConfirm.Visible = true;
                    //}
                    //else
                    //{
                    //    btnConfirm.Visible = false;
                    //}
                //}
            }
        }
Exemple #3
0
        //email
        public void sendEmailToSupplier(int eid,int poid)
        {
            purchaseorder po = new purchaseorder();
            po = access.getPurchaseOrderByPOID(poid);

            string ename = access.getENameByEid(eid);
            List<purchaseorderdetail> detail = new List<purchaseorderdetail>();
            detail = access.getPurchaseOrderDetailByPoid(poid);

            //string emailID = email;
            //send email
            MailMessage mail = new MailMessage();
            mail.From = new MailAddress("*****@*****.**");
            //mail.To.Add(new MailAddress(emailID));
            mail.To.Add(new MailAddress("*****@*****.**"));
            mail.Subject = "Purchase Order To Supplier :";
            String Header = "<head>"
                    + "<title>TODO supply a title</title>"
                    + "<meta charset=\"UTF-8\">"
                    + " <meta name=\"viewport\" content=\"width=device-width\">"
                    + " <link rel=\"stylesheet\" href=\"http://bootswatch.com/flatly/bootstrap.css\">"
                    + " <link rel=\"stylesheet\" href=\"http://bootswatch.com/assets/css/bootswatch.min.css\">"
                    + " </head>";
            String BodyStart = "<body>";
            String BodyContent = "<div class=\"bs-docs-section\">"
                    + ""
                    + "<div class=\"row\">"
                    + "<div class=\"col-lg-12\">"
                    + "<div class=\"page-header\">"
                    + "<h2 id=\"tables\">Purchase Order To Supplier</h2>"
                    + "</div>"
                    + "<div class=\"bs-example table-responsive\"><br/>"
                    + "Employee Name : " + ename + "<br/><br/><br/>"
                    + "Request Date : " + po.POReqDate.ToShortDateString() + "<br/><br/><br/>"
                    + "Request Deliver Date : " + po.POReqDeliverDate.ToShortDateString() + "<br/><br/><br/>"
                    + "<table class=\"table table-striped table-hover \">"
                    + "<thead>"
                    + " <tr>"
                    + "<th>Item ID</th>"
                    + " <th> Item Description </th>"
                    + "  <th> Quantity </th>"
                    + " </tr>"
                    + " </thead>";
            String TableContent = "<tbody>";
            foreach (purchaseorderdetail it in detail)
            {
                string itmname = access.getItmNameByItmid(it.POItemID);
                TableContent += "<tr>";
                TableContent += "<td>";
                TableContent += "<td>" + it.POItemID + "</td>";
                TableContent += "<td>" + itmname + "</td>";
                TableContent += "<td>" + it.POItemQuant + "</td>";
                TableContent += "</tr>";
            }

            mail.Body = Header + BodyStart + BodyContent + TableContent;

            mail.IsBodyHtml = true;

            SmtpClient sc = new SmtpClient();
            sc.Host = "smtp.gmail.com";
            sc.Port = 25;
            sc.Credentials = new System.Net.NetworkCredential("*****@*****.**", "12345678!");
            sc.EnableSsl = true;
            sc.Send(mail);
        }
Exemple #4
0
 public int createPurchaseOrder(purchaseorder r)
 {
     return access.createPurchaseOrder(r);
 }
        public bool UpdatePurchaseOrderDetailStatusApprove(int poid)
        {
            purchaseorder p = new purchaseorder();
            List<purchaseorderdetail> pd = new List<purchaseorderdetail>();
            item itm = new item();
            try
            {
                p = cntx.purchaseorders.Find(poid);
                p.PORecieveDate = DateTime.Now;

                pd = (from f in cntx.purchaseorderdetails where f.POID==poid select f).ToList();
                foreach (purchaseorderdetail dd in pd)
                {
                    int poQty = dd.POItemQuant;
                    dd.POStatus = "approved";
                    //increase item quantity
                    itm = (from it in cntx.items where it.ItemID == dd.POItemID select it).FirstOrDefault();
                    int itmQty = int.Parse(itm.ItemQuant.ToString());
                    int total = poQty + itmQty;
                    itm.ItemQuant = total;
                    //increase item quantity

                    //Include Tranaction Table
                    transaction tnew = new transaction();
                    tnew.TransItemID = itm.ItemID;
                    tnew.TransDate = DateTime.Now;
                    tnew.TransItemBalance = total;
                    tnew.TransItemQuant = poQty;
                    tnew.TransReason = "Recieved Purchase Order from Supplier";
                    tnew.TransactionType = "in";
                    tnew.TranUserID = Convert.ToInt32(System.Web.HttpContext.Current.Session["userid"]);
                    tnew.TransCode = "Purchase";
                    cntx.transactions.Add(tnew);

                }
                cntx.SaveChanges();
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 ////Purchase Order Detail
 public purchaseorder getPurchaseOrderByPOID(int poid)
 {
     purchaseorder po = new purchaseorder();
     try
     {
         po = (from p in cntx.purchaseorders where p.POID == poid select p).FirstOrDefault();
         return po;
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }