Exemplo n.º 1
0
        public ActionResult UploadPhoto(string name, string refno, DateTime tran_date, int id, HttpPostedFileBase file)
        {
            if (file != null)
            {
                if (file.FileName.Contains(".jpg") == false)
                {
                    Session["err"] = "Please Upload .JPG file Only";
                    return(RedirectToAction("Print", "Documents", new { id = id }));
                }
                else
                {
                    string path = Server.MapPath("~/photo/Documents");

                    file.SaveAs(path + "/" + id + ".jpg");
                    ViewData["path"] = id + ".jpg";
                    using (var db = new SameSoftWeb.Models.SameSoftwareWebEntities())
                    {
                        var x = db.TblDocuments.Add(new Models.TblDocument
                        {
                            Documents = "/Photo/Documents/" + id + ".jpg",
                            Cust_Name = name,
                            RefNo     = refno,
                            Tran_Date = tran_date
                        });
                        db.SaveChanges();
                    }
                }
            }
            else
            {
                Session["err"] = "No File Selected";
                return(RedirectToAction("Print", "Documents", new { id = id }));
            }
            return(RedirectToAction("Print", "Documents", new { id = id }));
        }
Exemplo n.º 2
0
        public static void addlog(string title, string details, int userid)
        {
            SameSoftWeb.Models.SameSoftwareWebEntities db = new SameSoftWeb.Models.SameSoftwareWebEntities();

            DateTime dt = DateTime.UtcNow.AddHours(3);

            db.TblLogs.Add(new Models.TblLog {
                LogDate = dt, Title = title, Details = details, UserID = userid
            });
            db.SaveChanges();
        }
Exemplo n.º 3
0
        public ActionResult add_purchase_request(int[] item_id, float[] qty, float[] unit_cost, int vendor_id, string note, DateTime?trandate)
        {
            int userid            = (int)Session["UserID"];
            int business_division = 1;


            DateTime vdate = SameSoftWeb.helper.sitemethods.getdate();

            if (trandate != null)
            {
                DateTime dt = (DateTime)trandate;
                if (dt.Date == vdate.Date)
                {
                    vdate = SameSoftWeb.helper.sitemethods.getdate();
                }
                else
                {
                    vdate = dt;
                }
            }

            // Validate
            db.Database.BeginTransaction();
            db.tblPurchase_Order.Add(new Models.tblPurchase_Order {
                Business_Division_Id = business_division, Total = 0, Tran_Date = vdate, Status = "Open", UserID = userid, Note = note, Vendor_Id = vendor_id
            });
            db.SaveChanges();
            int pur_id = 0;

            pur_id = db.tblPurchase_Order.Select(a => a.Purchase_ID).Max();

            for (int x = 0; x <= item_id.Length - 1; x++)
            {
                db.tblPurchase_Order_Details.Add(new Models.tblPurchase_Order_Details {
                    Purchase_ID = pur_id, Item_id = item_id[x], Qty = qty[x], Unit_Cost = unit_cost[x]
                });
                //   db.tblPurchase_Order_Details.Add(new Models.tblPurchase_Order_Details { Purchase_ID = pur_id, Item_id = item_id[x], Qty = qty[x] });


                //// Update Item Price / Cost
                //int id = item_id[x];
                //float costx = unit_cost[x];
                //var temp = db.Items.Where(a => a.Item_Id == id).FirstOrDefault();
                //if (temp!=null)
                //{
                //    temp.Sale_Price = (decimal)costx;
                //    db.SaveChanges();
                //}
            }
            db.SaveChanges();

            float total = 0;

            total = (float)db.tblPurchase_Order_Details.Where(a => a.Purchase_ID == pur_id).Select(a => a.Qty * a.Unit_Cost).Sum();
            var p = db.tblPurchase_Order.Where(f => f.Purchase_ID == pur_id).FirstOrDefault();

            p.Total = total;
            db.SaveChanges();


            db.Database.CurrentTransaction.Commit();

            //str = str + " All data Insetred";


            return(RedirectToAction("ReceivePurchase", "Purchasing"));

            //  return RedirectToAction("success", "message", new { msg = "Purchase Request Completed Successfully !" });
        }
Exemplo n.º 4
0
        public ActionResult PostRateNow(int[] Cust_ID, float[] amount, DateTime trandate)
        {
            int i = 0;

            int serialno = 0;
            int?sr       = db.tblInvoices.Where(a => a.Invoice_id == 1).Select(a => a.Invoice_No).FirstOrDefault();

            if (sr == null || sr == 0)
            {
                serialno = int.Parse(db.tblSettings.Where(a => a.ID == 1).Select(a => a.Value).FirstOrDefault());
            }
            else
            {
                serialno = (int)sr + 1;
            }
            int UserID = (int)Session["UserID"];

            for (int x = 0; x <= Cust_ID.Length - 1; x++)
            {
                int    ID           = Cust_ID[x];
                float  Mantainance  = amount[x];
                double balance      = 0;
                var    Cust_balance = db.sp_Get_Customer_with_Balance2(ID).FirstOrDefault();
                if (Cust_balance != null)
                {
                    balance = Cust_balance.Total;
                }
                string inwords      = helper.mnc.ToWords(Mantainance.ToString());
                string strTran_Nbr  = ID + DateTime.UtcNow.AddHours(3).ToString().GetHashCode().ToString("x");
                string tranNbr      = ID + DateTime.UtcNow.AddHours(3).ToString().GetHashCode().ToString("x");
                int?   Cust_Tran_ID = db.tblCustomer_Transaction.Where(a => a.CustomerID == ID && a.Status == "Open").Select(a => a.Cust_Tran_ID).FirstOrDefault();
                if (Cust_Tran_ID == null || Cust_Tran_ID == 0)
                {
                    db.tblCustomer_Transaction.Add(new Models.tblCustomer_Transaction
                    {
                        Amount     = Mantainance,
                        CustomerID = ID,
                        Tran_Date  = trandate,
                        Status     = "Open",
                        UserID     = UserID,
                    });

                    db.SaveChanges();
                    Cust_Tran_ID = db.tblCustomer_Transaction.Select(a => a.Cust_Tran_ID).Max();
                }
                else
                {
                    try
                    {
                        var   tran     = db.tblCustomer_Transaction.Where(a => a.CustomerID == ID && a.Status == "Open").FirstOrDefault();
                        float?balance2 = tran.Amount;

                        tran.Amount = (float)(balance + Mantainance);
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                    }
                }

                int Cust_Tran_Type = 0;
                Cust_Tran_Type = db.tblCustomer_Tran_Type.Where(a => a.Tran_Type == "Customer Invoice").Select(a => a.Cust_Tran_Type_ID).FirstOrDefault();

                db.tblCustomer_Transaction_Detail.Add(new Models.tblCustomer_Transaction_Detail
                {
                    Credit            = 0,
                    Debit             = Mantainance,
                    Cust_Tran_ID      = (int)Cust_Tran_ID,
                    Description       = "Mantainance",
                    Trans_Date        = trandate,
                    Cust_Tran_Type_ID = Cust_Tran_Type,
                    Tran_Nbr          = strTran_Nbr,
                    UserID            = UserID,
                    Unit_price        = Mantainance,
                    Qty        = 1,
                    Invoice_No = serialno,
                    Route      = inwords,
                    Status     = "Open",
                    Balance    = (float)balance
                });

                db.SaveChanges();
                float intTotal_Vendor_Balance = (float)db.Get_Total_Customer_Transaction_Detail_by_TranID(Cust_Tran_ID).FirstOrDefault();
                db.Update_Customer_Tranaction_Amount_By_Cust_tran_id(intTotal_Vendor_Balance, Cust_Tran_ID);

                var customername = db.tblCustomers.Where(a => a.CustomerID == ID).Select(a => a.Customer_Name).FirstOrDefault();

                // Add Journal

                db.tblJournals.Add(new Models.tblJournal
                {
                    Journal_Date = trandate,
                    Tran_Nbr     = strTran_Nbr,
                    TYear        = trandate.Year,
                    Period       = trandate.Month,
                    UserID       = UserID,
                    Status       = "Open",
                    Tran_Type    = "Customers",
                    Description  = "Customer Post",
                });
                db.SaveChanges();

                int Journal_id = db.tblJournals.Where(a => a.UserID == UserID).Select(a => a.Journal_id).Max();

                // AR
                db.tblJournal_Details.Add(new Models.tblJournal_Details {
                    Journal_id = Journal_id, Debit = Mantainance, Credit = 0, Account_Number = 1150
                });
                db.SaveChanges();
                // Income
                db.tblJournal_Details.Add(new Models.tblJournal_Details {
                    Journal_id = Journal_id, Debit = 0, Credit = Mantainance, Account_Number = 3130
                });
                db.SaveChanges(); int Journal_Detail_id = db.tblJournal_Details.Where(a => a.Journal_id == Journal_id).Select(a => a.Journal_Detail_id).Max();


                var y = db.tblInvoices.FirstOrDefault();
                if (y != null)
                {
                    y.Invoice_No = serialno;
                    db.SaveChanges();
                }
                i        += 1;
                serialno += 1;
            }



            return(RedirectToAction("CustomerPost", "Customers", new { msg = "Customer Posted Successfully for " + i + " Customer(s)" }));
        }