Exemple #1
0
        public static List <LocationVM> GetLocation(string term)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = new SqlConnection(CommanFunctions.GetConnectionString);
            cmd.CommandText = "SP_QryGetLocation";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@term", term);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);

            List <LocationVM> objList = new List <LocationVM>();

            if (ds != null && ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    LocationVM obj = new LocationVM();
                    obj.LocationID  = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["LocationID"].ToString());
                    obj.CityID      = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["CityID"].ToString());
                    obj.CountryID   = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["CountryID"].ToString());
                    obj.Location    = ds.Tables[0].Rows[i]["Location"].ToString();
                    obj.CityName    = ds.Tables[0].Rows[i]["City"].ToString();
                    obj.CountryName = ds.Tables[0].Rows[i]["CountryName"].ToString();
                    objList.Add(obj);
                }
            }
            return(objList);
        }
        // GET: CODReceipt
        public ActionResult Index()
        {
            DatePicker datePicker = SessionDataModel.GetTableVariable();
            DatePicker model      = new DatePicker();

            //string tz = "Arabian Standard Time";
            //DateTime now = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, tz);
            if (datePicker == null)
            {
                model = new DatePicker
                {
                    FromDate = CommanFunctions.GetFirstDayofMonth().Date,
                    ToDate   = CommanFunctions.GetLastDayofMonth().Date //DateTime.Now.Date.AddHours(23).AddMinutes(59).AddSeconds(59).AddHours(8)

                                                                        //      Delete = (bool)Token.Permissions.Deletion,
                                                                        //    Update = (bool)Token.Permissions.Updation,
                                                                        //  Create = (bool)Token.Permissions.Creation
                };
            }
            else
            {
                model.FromDate = datePicker.FromDate;
                model.ToDate   = datePicker.ToDate;
            }
            ViewBag.Token = model;
            SessionDataModel.SetTableVariable(model);
            return(View(model));
        }
        // GET: TruckAssign
        public ActionResult Index(string TDHNo, string FromDate, string ToDate)
        {
            SessionDataModel.ClearTableVariable();
            int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int depotId  = Convert.ToInt32(Session["CurrentDepotID"].ToString());
            int yearid   = Convert.ToInt32(Session["fyearid"].ToString());

            DateTime pFromDate;
            DateTime pToDate;
            string   pTDHNo = "";

            if (TDHNo == null)
            {
                pTDHNo = "";
            }
            else
            {
                pTDHNo = TDHNo;
            }
            if (FromDate == null || ToDate == null)
            {
                DateTime localDateTime1 = CommanFunctions.GetCurrentDateTime();
                pFromDate = localDateTime1.Date;                                 // DateTimeOffset.Now.Date;// CommanFunctions.GetFirstDayofMonth().Date; // DateTime.Now.Date; //.AddDays(-1) ; // FromDate = DateTime.Now;
                pToDate   = CommanFunctions.GetLastDayofMonth().Date.AddDays(1); // DateTime.Now.Date.AddDays(1); // // ToDate = DateTime.Now;
            }
            else
            {
                pFromDate = Convert.ToDateTime(FromDate); //.AddDays(-1);
                pToDate   = Convert.ToDateTime(ToDate).AddDays(1);
            }

            //List<TruckAssignVM> lst = (from truck in db.TruckDetails
            //                           join c in db.InScanMasters on truck.TruckDetailID equals c.TruckDetailId

            //                           where c.BranchID == branchid && c.DepotID == depotId

            //                           && (truck.TDDate >= pFromDate && c.TransactionDate < pToDate)
            //                           && (c.CourierStatusID == pStatusId || (pStatusId == 0))  //&& c.CourierStatusID >= 4)
            //                           && c.IsDeleted == false
            //                           orderby truck.TDDate descending, truck.ReceiptNo descending
            //                           select new TruckAssignVM { TruckDetailId = truck.TruckDetailID, TDDate = truck.TDDate, ReceiptNo = truck.ReceiptNo, VechileRegistrationNo = truck.RegNo, ConsignmentNo = c.ConsignmentNo, Consignor = c.Consignor, Consignee = c.Consignee, ConsignorCountryName = c.ConsignorCountryName, ConsigneeCountry = c.ConsigneeCountryName, InScanId = c.InScanID, InScanDate = c.TransactionDate }).ToList();  //, requestsource=subpet3.RequestTypeName
            List <TruckAssignVM> lst = RevenueDAO.GetTruckDetailConsignments(pTDHNo, "", pFromDate, pToDate);

            ViewBag.FromDate          = pFromDate.Date.ToString("dd-MM-yyyy");
            ViewBag.ToDate            = pToDate.Date.AddDays(-1).ToString("dd-MM-yyyy");
            ViewBag.CourierStatus     = db.CourierStatus.Where(cc => cc.CourierStatusID >= 4).ToList();
            ViewBag.CourierStatusList = db.CourierStatus.Where(cc => cc.CourierStatusID >= 4).ToList();
            ViewBag.StatusTypeList    = db.tblStatusTypes.ToList();
            ViewBag.CourierStatusId   = 0;
            ViewBag.StatusId          = pTDHNo;
            return(View(lst));
        }
Exemple #4
0
        public static List <RevenueUpdateMasterVM> GetRevenueUpdateList(string ConsignmentNote, DateTime FromDate, DateTime ToDate)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = new SqlConnection(CommanFunctions.GetConnectionString);
            cmd.CommandText = "SP_GetRevenueUpdateList";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@FromDate", SqlDbType.VarChar);
            cmd.Parameters["@FromDate"].Value = FromDate.ToString("MM/dd/yyyy");
            cmd.Parameters.Add("@ToDate", SqlDbType.VarChar);
            cmd.Parameters["@ToDate"].Value = ToDate.ToString("MM/dd/yyyy");
            cmd.Parameters.Add("@ConsignmentNo", SqlDbType.VarChar);
            if (ConsignmentNote == null)
            {
                ConsignmentNote = "";
            }
            cmd.Parameters["@ConsignmentNo"].Value = ConsignmentNote;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);

            List <RevenueUpdateMasterVM> objList = new List <RevenueUpdateMasterVM>();

            if (ds != null && ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    RevenueUpdateMasterVM obj = new RevenueUpdateMasterVM();
                    obj.ID                = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["ID"].ToString());
                    obj.ConsignmentNo     = ds.Tables[0].Rows[i]["ConsignmentNo"].ToString();
                    obj.ConsignmentDate   = Convert.ToDateTime(ds.Tables[0].Rows[i]["ConsignmentDate"].ToString()); // CommanFunctions.ParseDate(ds.Tables[0].Rows[i]["RecPayDate"].ToString());
                    obj.Currency          = ds.Tables[0].Rows[i]["CurrencyName"].ToString();
                    obj.PaymentType       = ds.Tables[0].Rows[i]["PaymentType"].ToString();
                    obj.InvoiceTo         = ds.Tables[0].Rows[i]["InvoiceTo"].ToString();
                    obj.DebitAccountName  = ds.Tables[0].Rows[i]["DebitAccountHead"].ToString();
                    obj.CreditAccountName = ds.Tables[0].Rows[i]["CreditAccountHead"].ToString();
                    obj.CustomerName      = ds.Tables[0].Rows[i]["CustomerName"].ToString();
                    if (ds.Tables[0].Rows[i]["Amount"] == DBNull.Value)
                    {
                        obj.Amount = 0;
                    }
                    else
                    {
                        obj.Amount = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["Amount"].ToString());
                    }
                    objList.Add(obj);
                }
            }
            return(objList);
        }
Exemple #5
0
        public static List <TruckAssignVM> GetTruckDetailConsignments(string TDHNo, string ConsignmentNote, DateTime FromDate, DateTime ToDate)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = new SqlConnection(CommanFunctions.GetConnectionString);
            cmd.CommandText = "SP_GetTruckAssignList";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@FromDate", SqlDbType.VarChar);
            cmd.Parameters["@FromDate"].Value = FromDate.ToString("MM/dd/yyyy");
            cmd.Parameters.Add("@ToDate", SqlDbType.VarChar);
            cmd.Parameters["@ToDate"].Value = ToDate.ToString("MM/dd/yyyy");
            cmd.Parameters.Add("@ConsignmentNo", SqlDbType.VarChar);
            if (ConsignmentNote == null)
            {
                ConsignmentNote = "";
            }
            cmd.Parameters["@ConsignmentNo"].Value = ConsignmentNote;

            cmd.Parameters.Add("@TDHNo", SqlDbType.VarChar);
            if (TDHNo == null)
            {
                TDHNo = "";
            }
            cmd.Parameters["@TDHNo"].Value = TDHNo;

            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);

            List <TruckAssignVM> objList = new List <TruckAssignVM>();

            if (ds != null && ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    TruckAssignVM obj = new TruckAssignVM();
                    obj.TruckDetailId         = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["TruckDetailId"].ToString());
                    obj.ReceiptNo             = ds.Tables[0].Rows[i]["ReceiptNo"].ToString();
                    obj.ConsignmentNo         = ds.Tables[0].Rows[i]["ConsignmentNo"].ToString();
                    obj.TDDate                = Convert.ToDateTime(ds.Tables[0].Rows[i]["TDDate"].ToString()); // CommanFunctions.ParseDate(ds.Tables[0].Rows[i]["RecPayDate"].ToString());
                    obj.RouteName             = ds.Tables[0].Rows[i]["RouteName"].ToString();
                    obj.VechileRegistrationNo = ds.Tables[0].Rows[i]["RegNo"].ToString();
                    obj.Rent         = Convert.ToDecimal(ds.Tables[0].Rows[i]["Rent"].ToString());
                    obj.OtherCharges = Convert.ToDecimal(ds.Tables[0].Rows[i]["OtherCharge"].ToString());
                    obj.TotalCharge  = Convert.ToDecimal(ds.Tables[0].Rows[i]["TotalCharge"].ToString());
                    objList.Add(obj);
                }
            }
            return(objList);
        }
Exemple #6
0
        public static List <RevenueUpdateDetailVM> GetRevenueUpdateDetail(int ID)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = new SqlConnection(CommanFunctions.GetConnectionString);
            cmd.CommandText = "SP_GetRevenueUpdateDetail";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@ID", SqlDbType.Int);
            cmd.Parameters["@ID"].Value = ID;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);

            List <RevenueUpdateDetailVM> objList = new List <RevenueUpdateDetailVM>();

            if (ds != null && ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    RevenueUpdateDetailVM obj = new RevenueUpdateDetailVM();
                    obj.ID                  = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["ID"].ToString());
                    obj.MasterID            = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["MasterID"].ToString());
                    obj.CurrencyId          = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["CurrencyId"].ToString());
                    obj.ExchangeRate        = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["ExchangeRate"].ToString());
                    obj.RevenueCostMasterID = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["RevenueCostMasterID"].ToString());
                    obj.RevenueCost         = ds.Tables[0].Rows[i]["RevenueComponent"].ToString();
                    obj.CustomerId          = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["CustomerId"].ToString());
                    obj.Amount              = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["Amount"].ToString());
                    obj.TaxPercent          = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["TaxPercent"].ToString());
                    obj.TaxAmount           = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["TaxAmount"].ToString());
                    obj.TotalCharge         = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["TotalCharge"].ToString());
                    obj.AcHeadDebitId       = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["AcHeadDebitId"].ToString());
                    obj.AcHeadCreditId      = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["AcHeadCreditId"].ToString());
                    obj.PaymentModeId       = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["PaymentModeId"].ToString());
                    obj.InvoiceTo           = ds.Tables[0].Rows[i]["InvoiceTo"].ToString();
                    obj.DebitAccountName    = ds.Tables[0].Rows[i]["DebitAccountHead"].ToString();
                    obj.CreditAccountName   = ds.Tables[0].Rows[i]["CreditAccountHead"].ToString();
                    obj.Currency            = ds.Tables[0].Rows[i]["CurrencyName"].ToString();
                    obj.CustomerName        = ds.Tables[0].Rows[i]["CustomerName"].ToString();
                    obj.PaymentType         = ds.Tables[0].Rows[i]["PaymentType"].ToString();
                    obj.InvoiceNo           = ds.Tables[0].Rows[i]["InvoiceNo"].ToString();
                    objList.Add(obj);
                }
            }
            return(objList);
        }
      // GET: SupplierInvoice
      public ActionResult Index(int?id, string FromDate, string ToDate)
      {
          int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());
          int depotId  = Convert.ToInt32(Session["CurrentDepotID"].ToString());

          DateTime pFromDate;
          DateTime pToDate;
          int      suppliertypeid = 0;

          if (id == null | id == 0)
          {
              suppliertypeid = 4;
          }
          else
          {
              suppliertypeid = Convert.ToInt32(id);
          }

          if (FromDate == null || ToDate == null)
          {
              pFromDate = CommanFunctions.GetFirstDayofMonth().Date;           //.AddDays(-1); // FromDate = DateTime.Now;
              pToDate   = CommanFunctions.GetLastDayofMonth().Date.AddDays(1); // // ToDate = DateTime.Now;
          }
          else
          {
              pFromDate = Convert.ToDateTime(FromDate);  //.AddDays(-1);
              pToDate   = Convert.ToDateTime(ToDate).AddDays(1);
          }

          var lst = (from c in db.SupplierInvoices
                     join s in db.SupplierMasters on c.SupplierID equals s.SupplierID orderby c.InvoiceDate descending
                     where s.SupplierTypeID == suppliertypeid
                     where c.InvoiceDate >= pFromDate && c.InvoiceDate < pToDate
                     select new SupplierInvoiceVM {
                SupplierInvoiceID = c.SupplierInvoiceID, InvoiceNo = c.InvoiceNo, InvoiceDate = c.InvoiceDate, SupplierName = s.SupplierName, Amount = 0, SupplierType = s.SupplierType.SupplierType1, Remarks = s.Remarks
            }).ToList();

          lst.ForEach(d => d.Amount = (from s in db.SupplierInvoiceDetails where s.SupplierInvoiceID == d.SupplierInvoiceID select s).ToList().Sum(a => a.Value));

          ViewBag.FromDate       = pFromDate.Date.ToString("dd-MM-yyyy");
          ViewBag.ToDate         = pToDate.Date.AddDays(-1).ToString("dd-MM-yyyy");
          ViewBag.SupplierType   = db.SupplierTypes.ToList();
          ViewBag.SupplierTypeId = suppliertypeid;
          return(View(lst));
      }
Exemple #8
0
        public static List <CustomerInvoiceDetailVM> GenerateInvoice(DateTime FromDate, DateTime ToDate, int CustomerId, int FYearId, int InvoiceId)
        {
            SqlCommand cmd = new SqlCommand();

            cmd.Connection  = new SqlConnection(CommanFunctions.GetConnectionString);
            cmd.CommandText = "SP_GenerateInvoice";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@FromDate", FromDate.ToString("MM/dd/yyyy"));
            cmd.Parameters.AddWithValue("@ToDate", ToDate.ToString("MM/dd/yyyy"));
            cmd.Parameters.AddWithValue("@CustomerId", CustomerId);
            cmd.Parameters.AddWithValue("@FYearId", FYearId);
            cmd.Parameters.AddWithValue("@InvoiceId", InvoiceId);

            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);

            List <CustomerInvoiceDetailVM> objList = new List <CustomerInvoiceDetailVM>();

            if (ds != null && ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    CustomerInvoiceDetailVM obj = new CustomerInvoiceDetailVM();
                    obj.CustomerInvoiceDetailID = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["CustomerInvoiceDetailID"].ToString());
                    obj.CustomerInvoiceID       = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["CustomerInvoiceID"].ToString());
                    obj.InScanID             = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["InScanId"].ToString());
                    obj.ConsignmentNo        = ds.Tables[0].Rows[i]["ConsignmentNo"].ToString();
                    obj.AWBDateTime          = Convert.ToDateTime(ds.Tables[0].Rows[i]["AWBDateTime"].ToString());
                    obj.FreightCharge        = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["FreightCharge"].ToString());
                    obj.DocCharge            = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["DocCharge"].ToString());
                    obj.CustomsCharge        = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["CustomsCharge"].ToString());
                    obj.OtherCharge          = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["OtherCharge"].ToString());
                    obj.TotalCharges         = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["TotalCharges"].ToString());
                    obj.ConsigneeName        = ds.Tables[0].Rows[i]["Consignee"].ToString();
                    obj.ConsigneeCountryName = ds.Tables[0].Rows[i]["ConsigneeCountryName"].ToString();
                    obj.Origin        = ds.Tables[0].Rows[i]["Consignor"].ToString();
                    obj.ConsigneeName = ds.Tables[0].Rows[i]["Consignee"].ToString();
                    objList.Add(obj);
                }
            }
            return(objList);
        }
Exemple #9
0
        public ActionResult InvoiceSearch()
        {
            DatePicker datePicker = SessionDataModel.GetTableVariable();

            if (datePicker == null)
            {
                datePicker            = new DatePicker();
                datePicker.FromDate   = CommanFunctions.GetFirstDayofMonth().Date; // DateTime.Now.Date;
                datePicker.ToDate     = DateTime.Now.Date.AddHours(23).AddMinutes(59).AddSeconds(59);
                datePicker.MovementId = "1,2,3,4";
            }
            if (datePicker != null)
            {
                //ViewBag.Customer = (from c in db.InScanMasters
                //                    join cust in db.CustomerMasters on c.CustomerID equals cust.CustomerID
                //                    where (c.TransactionDate >= datePicker.FromDate && c.TransactionDate < datePicker.ToDate)
                //                    select new CustmorVM { CustomerID = cust.CustomerID, CustomerName = cust.CustomerName }).Distinct();

                ViewBag.Customer = (from c in db.CustomerMasters where c.StatusActive == true select new CustmorVM {
                    CustomerID = c.CustomerID, CustomerName = c.CustomerName
                }).ToList();
                if (datePicker.MovementId == null)
                {
                    datePicker.MovementId = "1,2,3,4";
                }
            }
            else
            {
                ViewBag.Customer = new CustmorVM {
                    CustomerID = 0, CustomerName = ""
                };
            }


            //ViewBag.Movement = new MultiSelectList(db.CourierMovements.ToList(),"MovementID","MovementType");
            ViewBag.Movement = db.CourierMovements.ToList();

            ViewBag.Token = datePicker;
            SessionDataModel.SetTableVariable(datePicker);
            return(View(datePicker));
        }
Exemple #10
0
        public static List <CustomerInvoiceVM> GetInvoiceList(DateTime FromDate, DateTime ToDate, string InvoiceNo, int FyearId)
        {
            SqlCommand cmd           = new SqlCommand();
            string     strConnString = ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString;

            cmd.Connection  = new SqlConnection(strConnString);
            cmd.CommandText = "SP_GetInvoiceList";
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@FromDate", FromDate.ToString("MM/dd/yyyy"));
            cmd.Parameters.AddWithValue("@ToDate", ToDate.ToString("MM/dd/yyyy"));
            cmd.Parameters.AddWithValue("@FYearId", FyearId);
            if (InvoiceNo == null)
            {
                InvoiceNo = "";
            }
            cmd.Parameters.AddWithValue("@InvoiceNo", @InvoiceNo);

            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet        ds = new DataSet();

            da.Fill(ds);
            List <CustomerInvoiceVM> objList = new List <CustomerInvoiceVM>();
            CustomerInvoiceVM        obj;

            if (ds != null && ds.Tables.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    obj = new CustomerInvoiceVM();
                    obj.CustomerInvoiceID = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["CustomerInvoiceID"].ToString());
                    obj.CustomerInvoiceNo = ds.Tables[0].Rows[i]["CustomerInvoiceNo"].ToString();
                    obj.InvoiceDate       = Convert.ToDateTime(ds.Tables[0].Rows[i]["InvoiceDate"].ToString());
                    obj.CustomerName      = ds.Tables[0].Rows[i]["CustomerName"].ToString();
                    obj.CustomerID        = CommanFunctions.ParseInt(ds.Tables[0].Rows[i]["CustomerID"].ToString());
                    obj.InvoiceTotal      = CommanFunctions.ParseDecimal(ds.Tables[0].Rows[i]["InvoiceTotal"].ToString());
                    objList.Add(obj);
                }
            }
            return(objList);
        }
Exemple #11
0
        public ActionResult _ForgotPasswordFor([Bind(Include = "Email")] ForgotPasswordModel forgotpassword)
        {
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";

            if (ModelState.IsValid)
            {
                User superadminuser = db.Users.Find(1);
                User user           = db.Users.Where(u => u.Email == forgotpassword.Email).FirstOrDefault();
                if (user == null)
                {
                    Session["err"] = "Email is not available";
                    Session["msg"] = "";
                }
                else
                {
                    try
                    {
                        string To = forgotpassword.Email, WebsiteUrl, Ssl, UserID, Password, SMTPPort, Host;
                        CommanFunctions.AppSettings(out WebsiteUrl, out Ssl, out UserID, out Password, out SMTPPort, out Host);
                        string subject = "Reset Password";
                        string body    = "Hi,";
                        body += "<br/> Your password is : " + user.Password;
                        body += "<br/> <br/> ----------------------";
                        body += "<br/> Admin";
                        body += "<br/> <a href=" + WebsiteUrl + ">" + WebsiteUrl + "</a>";
                        CommanFunctions.SendEmail(UserID, subject, body, superadminuser.Email, To, Ssl, UserID, Password, SMTPPort, Host);
                        Session["err"] = "";
                        Session["msg"] = "Password was sent to your Email";
                    }
                    catch {
                        Session["err"] = "Email sending failed, please check smtp configuration.";
                    }
                }

                return(RedirectToAction("Login"));
            }

            return(Json(Session["err"], JsonRequestBehavior.AllowGet));
        }
Exemple #12
0
        public ActionResult Index()
        {
            CustomerInvoiceSearch obj   = (CustomerInvoiceSearch)Session["CustomerInvoiceSearch"];
            CustomerInvoiceSearch model = new CustomerInvoiceSearch();
            int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int depotId  = Convert.ToInt32(Session["CurrentDepotID"].ToString());
            int yearid   = Convert.ToInt32(Session["fyearid"].ToString());

            if (obj == null)
            {
                DateTime pFromDate;
                DateTime pToDate;
                //int pStatusId = 0;
                pFromDate     = CommanFunctions.GetFirstDayofMonth().Date;
                pToDate       = CommanFunctions.GetLastDayofMonth().Date;
                obj           = new CustomerInvoiceSearch();
                obj.FromDate  = pFromDate;
                obj.ToDate    = pToDate;
                obj.InvoiceNo = "";
                Session["CustomerInvoiceSearch"] = obj;
                model.FromDate  = pFromDate;
                model.ToDate    = pToDate;
                model.InvoiceNo = "";
            }
            else
            {
                model = obj;
            }
            List <CustomerInvoiceVM> lst = PickupRequestDAO.GetInvoiceList(obj.FromDate, obj.ToDate, model.InvoiceNo, yearid);

            if (lst != null)
            {
                model.InvoiceTotal = Convert.ToDecimal(lst.Sum(cc => cc.InvoiceTotal).ToString()); // ReceiptDAO.GetCustomerInvoiceTotal(obj.FromDate, obj.ToDate);
            }
            model.Details = lst;

            return(View(model));
        }
        public ActionResult Edit([Bind(Include = "EmployeeID,Name,IdCard,HouseNo,BuildingName,Street,Area,Location,CityID,CountryID,PinCode,Landline,Mobile,Photo,SchoolID,UserID,LeavesToAvail,Salary,Status,Email,Password")] EmployeeModel employeemodel, HttpPostedFileBase uploadlogo, string newlogo, string existingemail)
        {
            errordata data = new errordata();

            data.type      = "error";
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";
            try
            {
                if (ModelState.IsValid)
                {
                    if (employeemodel.Email != existingemail)
                    {
                        User employeeold = db.Users.Where(s => s.Email == employeemodel.Email).FirstOrDefault();
                        if (employeeold != null)
                        {
                            Session["err"] = "Email already exists";
                            data.message   = Session["err"].ToString();
                            return(Json(data, JsonRequestBehavior.AllowGet));
                        }
                    }
                    if (newlogo != "")
                    {
                        employeemodel.Photo = newlogo;
                    }

                    User superadminuser = db.Users.Find(1);

                    User user = db.Users.Find(employeemodel.UserID);
                    user.Email           = employeemodel.Email;
                    user.Password        = employeemodel.Password;
                    db.Entry(user).State = EntityState.Modified;
                    db.SaveChanges();

                    Employee employee = db.Employees.Find(employeemodel.EmployeeID);
                    employee.Name            = employeemodel.Name;
                    employee.IdCard          = employeemodel.IdCard;
                    employee.HouseNo         = employeemodel.HouseNo;
                    employee.BuildingName    = employeemodel.BuildingName;
                    employee.Street          = employeemodel.Street;
                    employee.Area            = employeemodel.Area;
                    employee.Location        = employeemodel.Location;
                    employee.CityID          = employeemodel.CityID;
                    employee.CountryID       = employeemodel.CountryID;
                    employee.PinCode         = employeemodel.PinCode;
                    employee.Landline        = employeemodel.Landline;
                    employee.Mobile          = employeemodel.Mobile;
                    employee.Photo           = employeemodel.Photo;
                    employee.SchoolID        = employeemodel.SchoolID;
                    employee.UserID          = employeemodel.UserID;
                    employee.LeavesToAvail   = employeemodel.LeavesToAvail;
                    employee.Salary          = employeemodel.Salary;
                    employee.Status          = employeemodel.Status;
                    db.Entry(employee).State = EntityState.Modified;
                    db.SaveChanges();

                    string To = employeemodel.Email, WebsiteUrl, Ssl, UserID, Password, SMTPPort, Host;
                    CommanFunctions.AppSettings(out WebsiteUrl, out Ssl, out UserID, out Password, out SMTPPort, out Host);
                    string subject = "Employee Modified";
                    string body    = "Hi,";
                    body += "<br/> Employee was modified. Please login using these credentials, and update employee profile. <br/> Login email : " + employeemodel.Email;
                    body += "<br/> Login password : "******"<br/> <br/> ----------------------";
                    body += "<br/> Admin";
                    body += "<br/> <a href=" + WebsiteUrl + ">" + WebsiteUrl + "</a>";
                    try { CommanFunctions.SendEmail(UserID, subject, body, superadminuser.Email, To, Ssl, UserID, Password, SMTPPort, Host); }
                    catch
                    {
                        //Session["err"] = "Email sending failed, please check smtp configuration.";
                        //data.message = Session["err"].ToString();
                        //return Json(data, JsonRequestBehavior.AllowGet);
                    }

                    Session["err"] = "";
                    Session["msg"] = "Modified Successfully";
                }
            }
            catch {
                data.message = Session["err"].ToString();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }

            data.message = "/Employee/Index";
            data.type    = "success";
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemple #14
0
        public ActionResult Index(int?StatusId, string FromDate, string ToDate)
        {
            DateTime pFromDate;
            DateTime pToDate;
            int      pStatusId = 0;

            if (StatusId == null)
            {
                pStatusId = 0;
            }
            else
            {
                pStatusId = Convert.ToInt32(StatusId);
            }
            if (FromDate == null || ToDate == null)
            {
                pFromDate = CommanFunctions.GetFirstDayofMonth().Date; //.AddDays(-1); // FromDate = DateTime.Now;
                pToDate   = DateTime.Now.Date.AddDays(1);              // // ToDate = DateTime.Now;
            }
            else
            {
                pFromDate = Convert.ToDateTime(FromDate);//.AddDays(-1);
                pToDate   = Convert.ToDateTime(ToDate).AddDays(1);
            }
            List <HoldVM> lst = new List <HoldVM>();

            int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int depotId  = Convert.ToInt32(Session["CurrentDepotID"].ToString());

            //List<HoldVM> ls = (from c in db.InScans join e in db.CountryMasters on c.ConsignorCityID equals e.CountryID join t in db.CityMasters on c.ConsigneeCityID equals t.CityID join x in db.CountryMasters on c.ConsigneeCountryID equals x.CountryID where c.HeldBy == null select new HoldVM { AWBNo = c.AWBNo, InScanID = c.InScanID, date = c.InScanDate, CollectedBy = c.CollectedBy, OriginName = e.CountryName, Consignor = c.Consignor, Consignee = c.Consignee, ConsigneeCountry = t.City, DestinationName = x.CountryName}).ToList();

            int statustypeid    = db.tblStatusTypes.Where(cc => cc.Name == "HOLD").FirstOrDefault().ID;
            int holdsatusid     = db.CourierStatus.Where(cc => cc.StatusTypeID == statustypeid && cc.CourierStatus == "OnHold").FirstOrDefault().CourierStatusID;
            int releasestatusid = db.CourierStatus.Where(cc => cc.StatusTypeID == statustypeid && cc.CourierStatus == "Released").FirstOrDefault().CourierStatusID;

            lst = (from c in db.InScanMasters join p in db.tblPaymentModes on c.PaymentModeId equals p.ID
                   join cs in db.CourierStatus on c.CourierStatusID equals cs.CourierStatusID
                   join hr in db.HoldReleases on c.InScanID equals hr.InScanId
                   join em in db.EmployeeMasters on c.PickedUpEmpID equals em.EmployeeID
                   where c.BranchID == branchid && c.StatusTypeId == statustypeid && //&& c.CourierStatusID == courisestatusid
                   (hr.EntryDate >= pFromDate && hr.EntryDate < pToDate) && (c.CourierStatusID == pStatusId || pStatusId == 0) &&
                   ((hr.ActionType == "Hold" && c.CourierStatusID == holdsatusid) || (hr.ActionType == "Release" && c.CourierStatusID == releasestatusid))
                   orderby hr.EntryDate descending
                   select new HoldVM {
                InScanID = c.InScanID, AWBNo = c.ConsignmentNo, date = hr.EntryDate,
                TransactionnDate = c.TransactionDate, CollectedByName = em.EmployeeName, Consignor = c.Consignor, OriginCountry = c.ConsignorCountryName, CourierStatus = cs.CourierStatus,
                Weight = c.Weight, Pieces = c.Pieces, CourierCharges = 100, Consignee = c.Consignee, ConsigneeCountry = c.ConsigneeCountryName, StatusPaymentMOde = p.PaymentModeText
            }).ToList();

            ViewBag.FromDate = pFromDate.Date.ToString("dd-MM-yyyy");
            ViewBag.ToDate   = pToDate.Date.AddDays(-1).ToString("dd-MM-yyyy");
            //foreach (var item in data)
            //{
            //    HoldVM obj = new HoldVM();
            //    if (item.HeldBy == null)
            //    {
            //        obj.InScanID = item.InScanID;
            //        obj.AWBNo = item.AWBNo;
            //        obj.date = item.TransactionDate;
            //        obj.CollectedBy = item.PickedUpEmpID;
            //        obj.StatedWeight = item.StatedWeight;
            //        obj.Pieces = item.Pieces;
            //        obj.CourierCharges = Convert.ToDecimal(item.CourierCharge);
            //        //obj.OriginID = item.ConsignorCountryID.Value;
            //        obj.Consignee = item.Consignee;
            //        obj.DestinationID = item.ConsigneeCountryName;
            //        obj.StatusPaymentMOde = db.tblStatusTypes
            //        obj.Consignor = item.Consignor;

            //        obj.HeldBy = item.HeldBy;
            //        obj.HeldOn = item.HeldOn;
            //        obj.HeldResoan = item.HeldReason;
            //    }
            //    lst.Add(obj);
            //}

            ViewBag.CourierStatusList = db.CourierStatus.Where(cc => cc.StatusType == "HOLD").ToList();
            ViewBag.ReleaseBy         = db.EmployeeMasters.ToList();
            return(View(lst));
        }
        public ActionResult Create([Bind(Include = "EmployeeID,Name,IdCard,HouseNo,BuildingName,Street,Area,Location,CityID,CountryID,PinCode,Landline,Mobile,Photo,SchoolID,UserID,LeavesToAvail,Salary,Status,Email,Password")] EmployeeModel employeemodel, HttpPostedFileBase uploadlogo, string newlogo)
        {
            errordata data = new errordata();

            data.type      = "error";
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";
            if (employeemodel.Salary <= 0)
            {
                Session["err"] = "Salary required";
                data.message   = Session["err"].ToString();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            if (employeemodel.Name != null)
            {
                try
                {
                    User employeeold = db.Users.Where(s => s.Email == employeemodel.Email).FirstOrDefault();
                    if (employeeold != null)
                    {
                        Session["err"] = "Email already exists";
                        data.message   = Session["err"].ToString();
                        return(Json(data, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        if (newlogo != "")
                        {
                            employeemodel.Photo = newlogo;
                        }
                        User superadminuser = db.Users.Find(1);

                        User user = new User();
                        user.Email        = employeemodel.Email;
                        user.Password     = employeemodel.Password;
                        user.CanCreate    = false;
                        user.CanEdit      = false;
                        user.CanDelete    = false;
                        user.CanPrint     = false;
                        user.Status       = false;
                        user.CreatedOn    = DateTime.Now;
                        user.LastLoggedOn = null;
                        db.Users.Add(user);
                        db.SaveChanges();

                        Role     role      = db.Roles.Where(r => r.Name == "Employee").FirstOrDefault();
                        UserRole userroles = new UserRole();
                        userroles.UserID = user.UserID;
                        userroles.RoleID = role.RoleID;
                        db.UserRoles.Add(userroles);
                        db.SaveChanges();

                        Employee employee = new Employee();
                        employee.Name          = employeemodel.Name;
                        employee.IdCard        = employeemodel.IdCard;
                        employee.HouseNo       = employeemodel.HouseNo;
                        employee.BuildingName  = employeemodel.BuildingName;
                        employee.Street        = employeemodel.Street;
                        employee.Area          = employeemodel.Area;
                        employee.Location      = employeemodel.Location;
                        employee.CityID        = employeemodel.CityID;
                        employee.CountryID     = employeemodel.CountryID;
                        employee.PinCode       = employeemodel.PinCode;
                        employee.Landline      = employeemodel.Landline;
                        employee.Mobile        = employeemodel.Mobile;
                        employee.Photo         = employeemodel.Photo;
                        employee.SchoolID      = employeemodel.SchoolID;
                        employee.UserID        = user.UserID;
                        employee.LeavesToAvail = employeemodel.LeavesToAvail;
                        employee.Salary        = employeemodel.Salary;
                        employee.Status        = employeemodel.Status;
                        db.Employees.Add(employee);
                        db.SaveChanges();

                        int    schoolid = Convert.ToInt16(Session["SchoolID"].ToString());
                        School school   = db.Schools.Find(schoolid);

                        employee.IdCard          = "" + school.ShortName.ToUpper() + "TEA" + employee.EmployeeID.ToString("D" + 6);
                        db.Entry(employee).State = EntityState.Modified;
                        db.SaveChanges();

                        user.Status          = true;
                        db.Entry(user).State = EntityState.Modified;
                        db.SaveChanges();

                        string To = employeemodel.Email, WebsiteUrl, Ssl, UserID, Password, SMTPPort, Host;
                        CommanFunctions.AppSettings(out WebsiteUrl, out Ssl, out UserID, out Password, out SMTPPort, out Host);
                        string subject = "New Employee Created";
                        string body    = "Hi,";
                        body += "<br/> Employee was created. Please login using these credentials, and update employee profile. <br/> Login email : " + employeemodel.Email;
                        body += "<br/> Login password : "******"<br/> <br/> ----------------------";
                        body += "<br/> Admin";
                        body += "<br/> <a href=" + WebsiteUrl + ">" + WebsiteUrl + "</a>";
                        try { CommanFunctions.SendEmail(UserID, subject, body, superadminuser.Email, To, Ssl, UserID, Password, SMTPPort, Host); }
                        catch {
                            //Session["err"] = "Email sending failed, please check smtp configuration.";
                            //data.message = Session["err"].ToString();
                            //return Json(data, JsonRequestBehavior.AllowGet);
                        }

                        Session["err"] = "";
                        Session["msg"] = "Created Successfully";
                    }
                }
                catch
                {
                    data.message = Session["err"].ToString();
                    return(Json(data, JsonRequestBehavior.AllowGet));
                }
            }

            data.message = "/Employee/Index";
            data.type    = "success";
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemple #16
0
        public ActionResult Create([Bind(Include = "StudentID,Name,IdCard,Dob,Mobile,ClassID,SectionID,GuardianName,GuardianMobile,GuardianEmail,Parent2Name,Parent2Mobile,Parent2Email,Photo,SchoolID,ParentID,UserID,Fee,FeeInstalments,Status,Email,Password")] StudentModel studentmodel, HttpPostedFileBase uploadlogo, string newlogo)
        {
            errordata data = new errordata();

            data.type      = "error";
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";
            if (studentmodel.Fee <= 0)
            {
                Session["err"] = "Fee required";
                data.message   = Session["err"].ToString();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }
            if (studentmodel.Name != null)
            {
                try
                {
                    User studentold = db.Users.Where(s => s.Email == studentmodel.Email).FirstOrDefault();
                    if (studentold != null)
                    {
                        Session["err"] = "Email already exists";
                        data.message   = Session["err"].ToString();
                        return(Json(data, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        if (newlogo != "")
                        {
                            studentmodel.Photo = newlogo;
                        }
                        User superadminuser = db.Users.Find(1);

                        User user = new User();
                        user.Email        = studentmodel.Email;
                        user.Password     = studentmodel.Password;
                        user.CanCreate    = false;
                        user.CanEdit      = false;
                        user.CanDelete    = false;
                        user.CanPrint     = false;
                        user.Status       = false;
                        user.CreatedOn    = DateTime.Now;
                        user.LastLoggedOn = null;
                        db.Users.Add(user);
                        db.SaveChanges();

                        Role     role      = db.Roles.Where(r => r.Name == "Student").FirstOrDefault();
                        UserRole userroles = new UserRole();
                        userroles.UserID = user.UserID;
                        userroles.RoleID = role.RoleID;
                        db.UserRoles.Add(userroles);
                        db.SaveChanges();

                        Student student = new Student();
                        student.Name      = studentmodel.Name;
                        student.IdCard    = studentmodel.IdCard;
                        student.Dob       = studentmodel.Dob;
                        student.Mobile    = studentmodel.Mobile;
                        student.ClassID   = studentmodel.ClassID;
                        student.SectionID = studentmodel.SectionID;

                        student.Photo          = studentmodel.Photo;
                        student.SchoolID       = studentmodel.SchoolID;
                        student.ParentID       = studentmodel.ParentID;
                        student.UserID         = user.UserID;
                        student.Fee            = studentmodel.Fee;
                        student.FeeInstalments = studentmodel.FeeInstalments;
                        student.Status         = studentmodel.Status;

                        student.GuardianName   = studentmodel.GuardianName;
                        student.GuardianMobile = studentmodel.GuardianMobile;
                        student.GuardianEmail  = studentmodel.GuardianEmail;

                        student.Parent2Name   = studentmodel.Parent2Name;
                        student.Parent2Mobile = studentmodel.Parent2Mobile;
                        student.Parent2Email  = studentmodel.Parent2Email;

                        db.Students.Add(student);
                        db.SaveChanges();

                        int    schoolid = Convert.ToInt16(Session["SchoolID"].ToString());
                        School school   = db.Schools.Find(schoolid);

                        student.IdCard          = "" + school.ShortName.ToUpper() + "STU" + student.StudentID.ToString("D" + 6);
                        db.Entry(student).State = EntityState.Modified;
                        db.SaveChanges();

                        user.Status          = true;
                        db.Entry(user).State = EntityState.Modified;
                        db.SaveChanges();

                        string To = studentmodel.Email, WebsiteUrl, Ssl, UserID, Password, SMTPPort, Host;
                        CommanFunctions.AppSettings(out WebsiteUrl, out Ssl, out UserID, out Password, out SMTPPort, out Host);
                        string subject = "New Student Created";
                        string body    = "Hi,";
                        body += "<br/> Student was created. Please login using these credentials, and update student profile. <br/> Login email : " + studentmodel.Email;
                        body += "<br/> Login password : "******"<br/> <br/> ----------------------";
                        body += "<br/> Admin";
                        body += "<br/> <a href=" + WebsiteUrl + ">" + WebsiteUrl + "</a>";
                        try { CommanFunctions.SendEmail(UserID, subject, body, superadminuser.Email, To, Ssl, UserID, Password, SMTPPort, Host); }
                        catch {
                            //Session["err"] = "Email sending failed, please check smtp configuration.";
                            //data.message = Session["err"].ToString();
                            //return Json(data, JsonRequestBehavior.AllowGet);
                        }

                        Session["err"] = "";
                        Session["msg"] = "Created Successfully";
                    }
                }
                catch
                {
                    data.message = Session["err"].ToString();
                    return(Json(data, JsonRequestBehavior.AllowGet));
                }
            }

            data.message = "/Student/Index";
            data.type    = "success";
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemple #17
0
        public ActionResult Edit([Bind(Include = "StudentID,Name,IdCard,Dob,Mobile,ClassID,SectionID,GuardianName,GuardianMobile,GuardianEmail,Parent2Name,Parent2Mobile,Parent2Email,Photo,SchoolID,ParentID,UserID,Status,Fee,FeeInstalments,Email,Password")] StudentModel studentmodel, HttpPostedFileBase uploadlogo, string newlogo, string existingemail)
        {
            errordata data = new errordata();

            data.type      = "error";
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";
            try
            {
                if (studentmodel.Email != "")
                {
                    if (studentmodel.Email != existingemail)
                    {
                        User studentold = db.Users.Where(s => s.Email == studentmodel.Email).FirstOrDefault();
                        if (studentold != null)
                        {
                            Session["err"] = "Email already exists";
                            data.message   = Session["err"].ToString();
                            return(Json(data, JsonRequestBehavior.AllowGet));
                        }
                    }
                    if (newlogo != "")
                    {
                        studentmodel.Photo = newlogo;
                    }

                    User superadminuser = db.Users.Find(1);

                    User user = db.Users.Find(studentmodel.UserID);
                    user.Email           = studentmodel.Email;
                    user.Password        = studentmodel.Password;
                    db.Entry(user).State = EntityState.Modified;
                    db.SaveChanges();

                    Student student = db.Students.Find(studentmodel.StudentID);
                    student.Name      = studentmodel.Name;
                    student.Dob       = studentmodel.Dob;
                    student.Mobile    = studentmodel.Mobile;
                    student.IdCard    = studentmodel.IdCard;
                    student.ClassID   = studentmodel.ClassID;
                    student.SectionID = studentmodel.SectionID;

                    student.Photo          = studentmodel.Photo;
                    student.SchoolID       = studentmodel.SchoolID;
                    student.ParentID       = studentmodel.ParentID;
                    student.UserID         = studentmodel.UserID;
                    student.Fee            = studentmodel.Fee;
                    student.FeeInstalments = studentmodel.FeeInstalments;
                    student.Status         = studentmodel.Status;

                    student.GuardianName   = studentmodel.GuardianName;
                    student.GuardianMobile = studentmodel.GuardianMobile;
                    student.GuardianEmail  = studentmodel.GuardianEmail;

                    student.Parent2Name   = studentmodel.Parent2Name;
                    student.Parent2Mobile = studentmodel.Parent2Mobile;
                    student.Parent2Email  = studentmodel.Parent2Email;

                    db.Entry(student).State = EntityState.Modified;
                    db.SaveChanges();

                    string To = studentmodel.Email, WebsiteUrl, Ssl, UserID, Password, SMTPPort, Host;
                    CommanFunctions.AppSettings(out WebsiteUrl, out Ssl, out UserID, out Password, out SMTPPort, out Host);
                    string subject = "Student Modified";
                    string body    = "Hi,";
                    body += "<br/> Student was modified. Please login using these credentials, and update student profile. <br/> Login email : " + studentmodel.Email;
                    body += "<br/> Login password : "******"<br/> <br/> ----------------------";
                    body += "<br/> Admin";
                    body += "<br/> <a href=" + WebsiteUrl + ">" + WebsiteUrl + "</a>";
                    try { CommanFunctions.SendEmail(UserID, subject, body, superadminuser.Email, To, Ssl, UserID, Password, SMTPPort, Host); }
                    catch
                    {
                        //Session["err"] = "Email sending failed, please check smtp configuration.";
                        //data.message = Session["err"].ToString();
                        //return Json(data, JsonRequestBehavior.AllowGet);
                    }

                    Session["err"] = "";
                    Session["msg"] = "Modified Successfully";
                }
            }
            catch {
                data.message = Session["err"].ToString();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }

            data.message = "/Student/Index";
            data.type    = "success";
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create([Bind(Include = "ParentID,Name,HouseNo,BuildingName,Street,Area,Location,CityID,CountryID,PinCode,Landline,Mobile,Photo,SchoolID,UserID,Status,Email,Password")] ParentModel parentmodel, HttpPostedFileBase uploadlogo, string newlogo)
        {
            errordata data = new errordata();

            data.type      = "error";
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";
            if (parentmodel.Name != null)
            {
                try
                {
                    User parentold = db.Users.Where(s => s.Email == parentmodel.Email).FirstOrDefault();
                    if (parentold != null)
                    {
                        Session["err"] = "Email already exists";
                        data.message   = Session["err"].ToString();
                        return(Json(data, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        if (newlogo != "")
                        {
                            parentmodel.Photo = newlogo;
                        }
                        User superadminuser = db.Users.Find(1);

                        User user = new User();
                        user.Email        = parentmodel.Email;
                        user.Password     = parentmodel.Password;
                        user.CanCreate    = false;
                        user.CanEdit      = false;
                        user.CanDelete    = false;
                        user.CanPrint     = false;
                        user.Status       = false;
                        user.CreatedOn    = DateTime.Now;
                        user.LastLoggedOn = null;
                        db.Users.Add(user);
                        db.SaveChanges();


                        Role     role      = db.Roles.Where(r => r.Name == "Parent").FirstOrDefault();
                        UserRole userroles = new UserRole();
                        userroles.UserID = user.UserID;
                        userroles.RoleID = role.RoleID;
                        db.UserRoles.Add(userroles);
                        db.SaveChanges();

                        Parent parent = new Parent();
                        parent.Name         = parentmodel.Name;
                        parent.HouseNo      = parentmodel.HouseNo;
                        parent.BuildingName = parentmodel.BuildingName;
                        parent.Street       = parentmodel.Street;
                        parent.Area         = parentmodel.Area;
                        parent.Location     = parentmodel.Location;
                        parent.CityID       = parentmodel.CityID;
                        parent.CountryID    = parentmodel.CountryID;
                        parent.PinCode      = parentmodel.PinCode;
                        parent.Landline     = parentmodel.Landline;
                        parent.Mobile       = parentmodel.Mobile;
                        parent.Photo        = parentmodel.Photo;
                        parent.SchoolID     = parentmodel.SchoolID;
                        parent.UserID       = user.UserID;
                        parent.Status       = parentmodel.Status;
                        db.Parents.Add(parent);
                        db.SaveChanges();

                        user.Status          = true;
                        db.Entry(user).State = EntityState.Modified;
                        db.SaveChanges();

                        string To = parentmodel.Email, WebsiteUrl, Ssl, UserID, Password, SMTPPort, Host;
                        CommanFunctions.AppSettings(out WebsiteUrl, out Ssl, out UserID, out Password, out SMTPPort, out Host);
                        string subject = "New Parent Created";
                        string body    = "Hi,";
                        body += "<br/> Parent was created. Please login using these credentials, and update parent profile. <br/> Login email : " + parentmodel.Email;
                        body += "<br/> Login password : "******"<br/> <br/> ----------------------";
                        body += "<br/> Admin";
                        body += "<br/> <a href=" + WebsiteUrl + ">" + WebsiteUrl + "</a>";
                        try { CommanFunctions.SendEmail(UserID, subject, body, superadminuser.Email, To, Ssl, UserID, Password, SMTPPort, Host); }
                        catch {
                            //Session["err"] = "Email sending failed, please check smtp configuration.";
                            //data.message = Session["err"].ToString();
                            //return Json(data, JsonRequestBehavior.AllowGet);
                        }

                        Session["err"] = "";
                        Session["msg"] = "Created Successfully";
                    }
                }
                catch {
                    data.message = Session["err"].ToString();
                    return(Json(data, JsonRequestBehavior.AllowGet));
                }
            }

            data.message = "/Parent/Index";
            data.type    = "success";
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemple #19
0
        public ActionResult Index(string VehicleType, string FromDate, string ToDate)
        {
            ViewBag.Employee            = db.EmployeeMasters.ToList();
            ViewBag.PickupRequestStatus = db.PickUpRequestStatus.ToList();

            int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int depotId  = Convert.ToInt32(Session["CurrentDepotID"].ToString());

            DateTime pFromDate;
            DateTime pToDate;
            int      pStatusId = 0;

            if (FromDate == null || ToDate == null)
            {
                pFromDate = CommanFunctions.GetFirstDayofMonth().Date;           //.AddDays(-1); // FromDate = DateTime.Now;
                pToDate   = CommanFunctions.GetLastDayofMonth().Date.AddDays(1); // // ToDate = DateTime.Now;
            }
            else
            {
                pFromDate = Convert.ToDateTime(FromDate);//.AddDays(-1);
                pToDate   = Convert.ToDateTime(ToDate).AddDays(1);
            }

            // List<PickupRequestVM> lst = (from c in db.CustomerEnquiries join t1 in db.EmployeeMasters on c.CollectedEmpID equals t1.EmployeeID join t2 in db.EmployeeMasters on c.EmployeeID equals t2.EmployeeID select new PickupRequestVM { EnquiryID = c.EnquiryID, EnquiryDate = c.EnquiryDate, Consignor = c.Consignor, Consignee = c.Consignee, eCollectedBy = t1.EmployeeName, eAssignedTo = t2.EmployeeName,AWBNo=c.AWBNo }).ToList();

            //List<PickupRequestVM> lst = (from c in db.CustomerEnquiries
            //            join status in db.PickUpRequestStatus on c.PickupRequestStatusId equals status.Id
            //            join pet in db.EmployeeMasters on c.CollectedEmpID equals pet.EmployeeID into gj
            //            from subpet in gj.DefaultIfEmpty()
            //            join pet1 in db.EmployeeMasters on c.EmployeeID equals  pet1.EmployeeID into gj1
            //            from subpet1 in gj1.DefaultIfEmpty()
            //            where  c.EnquiryDate >=pFromDate &&  c.EnquiryDate <=pToDate
            //            select new PickupRequestVM { EnquiryID = c.EnquiryID, EnquiryNo=c.EnquiryNo, EnquiryDate = c.EnquiryDate, Consignor = c.Consignor, Consignee = c.Consignee, eCollectedBy =subpet.EmployeeName ?? string.Empty, eAssignedTo = subpet1.EmployeeName ?? string.Empty , AWBNo = c.AWBNo ,PickupRequestStatus=status.PickRequestStatus }).ToList();

            int Customerid = 0;

            if (Session["UserType"].ToString() == "Customer")
            {
                Customerid = Convert.ToInt32(Session["CustomerId"].ToString());
            }
            List <TruckDetailVM> lst = (from c in db.TruckDetails
                                        //join d in db.DriverMasters on c.DriverID equals d.DriverID
                                        //join o in db.LocationMasters on c.OriginName equals o.LocationID
                                        //join de in db.LocationMasters on c.DestinationName equals de.LocationID
                                        where c.BranchID == branchid && (c.TDDate >= pFromDate && c.TDDate < pToDate) && (c.IsDeleted == false || c.IsDeleted == null)
                                        orderby c.TDDate descending
                                        select new TruckDetailVM {
                TruckDetailID = c.TruckDetailID,
                ReceiptNo = c.ReceiptNo,
                //DriverName=d.DriverName,
                Origin = c.OriginName,
                Destination = c.DestinationName,
                VehicleType = c.VehicleType,
                TDDate = c.TDDate,
                RegNo = c.RegNo,
                DriverID = c.DriverID,
                Rent = c.Rent,
                OtherCharges = c.OtherCharges,
                TotalCharge = c.Rent + c.OtherCharges
            }).ToList();


            if (!String.IsNullOrEmpty(VehicleType))
            {
                lst = lst.Where(d => d.VehicleType == VehicleType).ToList();
            }
            lst.ForEach(d => d.DriverName = (from s in db.DriverMasters where s.DriverID == d.DriverID select s).FirstOrDefault() == null ? "" : (from s in db.DriverMasters where s.DriverID == d.DriverID select s).FirstOrDefault().DriverName);

            ViewBag.FromDate = pFromDate.Date.ToString("dd-MM-yyyy");
            ViewBag.ToDate   = pToDate.Date.AddDays(-1).ToString("dd-MM-yyyy");
            ViewBag.StatusId = VehicleType;


            return(View(lst));
        }
        public ActionResult Create(int id = 0)
        {
            int fyearid = Convert.ToInt32(Session["fyearid"].ToString());

            //ViewBag.customer = db.CustomerMasters.Where(d => d.CustomerType == "CR").OrderBy(x => x.CustomerName).ToList();
            ViewBag.achead = db.AcHeads.ToList();

            if (id == 0)
            {
                ViewBag.Title = "CREDIT NOTE/CUSTOMER JOURNAL";
                CreditNoteVM vm = new CreditNoteVM();
                vm.CreditNoteNo       = AccountsDAO.GetMaxCreditNoteNo(fyearid);
                vm.Date               = CommanFunctions.GetLastDayofMonth().Date;
                vm.TransType          = "";
                vm.AcHeadID           = 52; //Customer control account
                vm.AmountType         = "0";
                vm.AcDetailAmountType = "1";
                List <CreditNoteDetailVM> list = new List <CreditNoteDetailVM>();
                vm.Details = list;

                Session["CreditNoteDetail"] = list;

                return(View(vm));
            }
            else
            {
                ViewBag.Title = "CREDIT NOTE/CUSTOMER JOURNAL - Modify";
                CreditNoteVM vm = new CreditNoteVM();
                var          v  = db.CreditNotes.Find(id);
                vm.CreditNoteID = v.CreditNoteID;
                vm.CreditNoteNo = v.CreditNoteNo;
                vm.Date         = Convert.ToDateTime(v.CreditNoteDate);
                vm.AcJournalID  = Convert.ToInt32(v.AcJournalID);
                vm.CustomerID   = Convert.ToInt32(v.CustomerID);
                var customer = db.CustomerMasters.Find(v.CustomerID).CustomerName;
                if (customer != null)
                {
                    vm.CustomerName = customer;
                }
                vm.AcHeadID    = Convert.ToInt32(v.AcHeadID);
                vm.Amount      = Convert.ToDecimal(v.Amount);
                vm.Description = v.Description;
                vm.TransType   = v.TransType;
                if (v.RecPayID != null && v.RecPayID != 0)
                {
                    vm.RecPayID = Convert.ToInt32(v.RecPayID);
                }
                else
                {
                    vm.RecPayID = 0;
                }

                var detaillist = (from c in db.CreditNoteDetails join d in db.AcHeads on c.AcHeadID equals d.AcHeadID where c.CreditNoteID == v.CreditNoteID select new CreditNoteDetailVM {
                    AcHeadID = c.AcHeadID, AcHeadName = d.AcHead1, Amount = c.Amount, Remarks = c.Remarks
                }).ToList();
                vm.Details = detaillist;
                Session["CreditNoteDetail"] = detaillist;
                if (v.InvoiceID != null && v.InvoiceID != 0 && v.TransType == "CN")
                {
                    vm.InvoiceID   = Convert.ToInt32(v.InvoiceID);
                    vm.InvoiceType = v.InvoiceType;
                    vm.ForInvoice  = true;


                    SetTradeInvoiceOfCustomer(vm.CustomerID, 0, vm.CreditNoteID, vm.TransType);
                    List <CustomerTradeReceiptVM> lst = (List <CustomerTradeReceiptVM>)Session["CustomerInvoice"];

                    if (v.InvoiceType == "TR")
                    {
                        var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "TR").FirstOrDefault();
                        if (invoice != null)
                        {
                            vm.InvoiceNo      = invoice.InvoiceNo;
                            vm.InvoiceDate    = invoice.DateTime;
                            vm.InvoiceAmount  = Convert.ToDecimal(invoice.InvoiceAmount);
                            vm.ReceivedAmount = Convert.ToDecimal(invoice.AmountReceived);
                        }
                    }
                    else if (v.InvoiceType == "OP")
                    {
                        //var invoice1 = db.AcOPInvoiceDetails.Where(cc=>cc.AcOPInvoiceDetailID ==vm.InvoiceID).FirstOrDefault();
                        //if (invoice1 != null)
                        //{
                        //    vm.InvoiceNo = invoice1.InvoiceNo;
                        //    vm.InvoiceDate = Convert.ToDateTime(invoice1.InvoiceDate).ToString("dd/MM/yyyy");
                        //    vm.InvoiceAmount = Convert.ToDecimal(invoice1.Amount);
                        //}
                        var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "OP").FirstOrDefault();
                        vm.InvoiceNo      = invoice.InvoiceNo;
                        vm.InvoiceDate    = invoice.DateTime;
                        vm.InvoiceAmount  = Convert.ToDecimal(invoice.InvoiceAmount);
                        vm.ReceivedAmount = Convert.ToDecimal(invoice.AmountReceived);
                    }
                }
                else if (v.RecPayID != null && v.RecPayID != 0 && v.TransType == "CJ")
                {
                    vm.InvoiceID   = Convert.ToInt32(v.RecPayID);
                    vm.InvoiceType = v.InvoiceType;
                    vm.ForInvoice  = true;

                    SetTradeInvoiceOfCustomer(vm.CustomerID, 0, vm.CreditNoteID, vm.TransType);
                    List <CustomerTradeReceiptVM> lst = (List <CustomerTradeReceiptVM>)Session["CustomerInvoice"];

                    if (v.InvoiceType == "TR")
                    {
                        var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "TR").FirstOrDefault();
                        if (invoice != null)
                        {
                            vm.InvoiceNo      = invoice.InvoiceNo;
                            vm.InvoiceDate    = invoice.DateTime;
                            vm.InvoiceAmount  = Convert.ToDecimal(invoice.InvoiceAmount);
                            vm.ReceivedAmount = Convert.ToDecimal(invoice.AmountReceived);
                        }
                    }
                    else if (v.InvoiceType == "OP")
                    {
                        var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "OP").FirstOrDefault();
                        vm.InvoiceNo      = invoice.InvoiceNo;
                        vm.InvoiceDate    = invoice.DateTime;
                        vm.InvoiceAmount  = Convert.ToDecimal(invoice.InvoiceAmount);
                        vm.ReceivedAmount = Convert.ToDecimal(invoice.AmountReceived);
                    }
                }
                else
                {
                    vm.ForInvoice = false;
                }


                vm.Date = Convert.ToDateTime(v.CreditNoteDate);
                //vm.
                return(View(vm));
            }
        }
        public ActionResult Edit([Bind(Include = "SchoolID,Name,ShortName,HouseNo,BuildingName,Street,Area,Location,CityID,CountryID,PinCode,Landline,Mobile,Website,RegNo,Logo,Principal,UserID,CompanyAcademicYearID,Status,Email,Password")] SchoolModel schoolmodel, HttpPostedFileBase uploadlogo, string newlogo, string existingemail)
        {
            errordata data = new errordata();

            data.type      = "error";
            Session["err"] = "Error, Please Check Input Fields";
            Session["msg"] = "";
            try
            {
                if (ModelState.IsValid)
                {
                    if (schoolmodel.Email != existingemail)
                    {
                        User schoolold = db.Users.Where(s => s.Email == schoolmodel.Email).FirstOrDefault();
                        if (schoolold != null)
                        {
                            Session["err"] = "Email already exists";
                            data.message   = Session["err"].ToString();
                            return(Json(data, JsonRequestBehavior.AllowGet));
                        }
                    }

                    //string newfilename = Guid.NewGuid().ToString();
                    //string logopath = schoolmodel.Logo;
                    //if (uploadlogo != null)
                    //{
                    //    var fileName = Path.GetFileName(uploadlogo.FileName);
                    //    var extention = Path.GetExtension(uploadlogo.FileName);
                    //    var filenamewithoutextension = Path.GetFileNameWithoutExtension(uploadlogo.FileName);
                    //    try
                    //    {
                    //        uploadlogo.SaveAs(Server.MapPath("/Uploads/" + newfilename + "." + extention));
                    //        logopath = "/Uploads/" + newfilename + "." + extention;
                    //        schoolmodel.Logo = logopath;
                    //    }
                    //    catch {
                    //        Session["err"] = "Can't upload file, please contact support";
                    //        data.message = Session["err"].ToString();
                    //        return Json(data, JsonRequestBehavior.AllowGet);
                    //    }

                    //}

                    if (newlogo != "")
                    {
                        schoolmodel.Logo = newlogo;
                    }

                    User superadminuser = db.Users.Find(1);

                    User user = db.Users.Find(schoolmodel.UserID);
                    user.Email           = schoolmodel.Email;
                    user.Password        = schoolmodel.Password;
                    db.Entry(user).State = EntityState.Modified;
                    db.SaveChanges();

                    School school = db.Schools.Find(schoolmodel.SchoolID);
                    school.Name                  = schoolmodel.Name;
                    school.ShortName             = schoolmodel.ShortName;
                    school.HouseNo               = schoolmodel.HouseNo;
                    school.BuildingName          = schoolmodel.BuildingName;
                    school.Street                = schoolmodel.Street;
                    school.Area                  = schoolmodel.Area;
                    school.Location              = schoolmodel.Location;
                    school.CityID                = schoolmodel.CityID;
                    school.CountryID             = schoolmodel.CountryID;
                    school.PinCode               = schoolmodel.PinCode;
                    school.Landline              = schoolmodel.Landline;
                    school.Mobile                = schoolmodel.Mobile;
                    school.Website               = schoolmodel.Website;
                    school.RegNo                 = schoolmodel.RegNo;
                    school.Logo                  = schoolmodel.Logo;
                    school.Principal             = schoolmodel.Principal;
                    school.UserID                = schoolmodel.UserID;
                    school.CompanyAcademicYearID = schoolmodel.CompanyAcademicYearID;
                    school.Status                = schoolmodel.Status;
                    db.Entry(school).State       = EntityState.Modified;
                    db.SaveChanges();

                    string To = schoolmodel.Email, WebsiteUrl, Ssl, UserID, Password, SMTPPort, Host;
                    CommanFunctions.AppSettings(out WebsiteUrl, out Ssl, out UserID, out Password, out SMTPPort, out Host);
                    string subject = "School Modified";
                    string body    = "Hi,";
                    body += "<br/> School was modified. Please login using these credentials, and update school profile. <br/> Login email : " + schoolmodel.Email;
                    body += "<br/> Login password : "******"<br/> <br/> ----------------------";
                    body += "<br/> Admin";
                    body += "<br/> <a href=" + WebsiteUrl + ">" + WebsiteUrl + "</a>";
                    try { CommanFunctions.SendEmail(UserID, subject, body, superadminuser.Email, To, Ssl, UserID, Password, SMTPPort, Host); }
                    catch
                    {
                        //Session["err"] = "Email sending failed, please check smtp configuration.";
                        //data.message = Session["err"].ToString();
                        //return Json(data, JsonRequestBehavior.AllowGet);
                    }

                    Session["err"] = "";
                    Session["msg"] = "Modified Successfully";
                }
            }
            catch {
                data.message = Session["err"].ToString();
                return(Json(data, JsonRequestBehavior.AllowGet));
            }

            data.message = "/School/Index";
            data.type    = "success";
            return(Json(data, JsonRequestBehavior.AllowGet));
        }
Exemple #22
0
        public ActionResult Create(CustomerInvoiceVM model)
        {
            int branchid  = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int companyId = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            var userid    = Convert.ToInt32(Session["UserID"]);
            int yearid    = Convert.ToInt32(Session["fyearid"].ToString());

            if (model.CustomerInvoiceID == 0)
            {
                CustomerInvoice _custinvoice = new CustomerInvoice();
                var             max          = db.CustomerInvoices.Select(x => x.CustomerInvoiceID).DefaultIfEmpty(0).Max() + 1;
                _custinvoice.CustomerInvoiceID = max;
                _custinvoice.CustomerInvoiceNo = model.CustomerInvoiceNo;
                _custinvoice.InvoiceDate       = model.InvoiceDate;
                _custinvoice.CustomerID        = model.CustomerID;
                //_custinvoice.CustomerInvoiceTax = model.CustomerInvoiceTax;
                //_custinvoice.ChargeableWT = model.ChargeableWT;
                //_custinvoice.AdminPer = model.AdminPer;
                //_custinvoice.AdminAmt = model.AdminAmt;
                //_custinvoice.FuelPer = model.FuelPer;
                //_custinvoice.FuelAmt = model.FuelAmt;
                //_custinvoice.OtherCharge = model.OtherCharge;
                _custinvoice.InvoiceTotal      = model.InvoiceTotal;
                _custinvoice.AcFinancialYearID = yearid;
                _custinvoice.AcCompanyID       = companyId;
                _custinvoice.BranchID          = branchid;
                _custinvoice.Remarks           = model.Remarks;
                _custinvoice.CreatedBy         = userid;
                _custinvoice.CreatedDate       = CommanFunctions.GetCurrentDateTime();
                _custinvoice.ModifiedBy        = userid;
                _custinvoice.ModifiedDate      = CommanFunctions.GetCurrentDateTime();
                db.CustomerInvoices.Add(_custinvoice);
                db.SaveChanges();

                List <CustomerInvoiceDetailVM> e_Details = model.CustomerInvoiceDetailsVM; //  Session["InvoiceListing"] as List<CustomerInvoiceDetailVM>;

                model.CustomerInvoiceDetailsVM = e_Details;

                if (model.CustomerInvoiceDetailsVM != null)
                {
                    foreach (var e_details in model.CustomerInvoiceDetailsVM)
                    {
                        if (e_details.CustomerInvoiceDetailID == 0 && e_details.AWBChecked)
                        {
                            CustomerInvoiceDetail _detail = new CustomerInvoiceDetail();
                            _detail.CustomerInvoiceDetailID = db.CustomerInvoiceDetails.Select(x => x.CustomerInvoiceDetailID).DefaultIfEmpty(0).Max() + 1;
                            _detail.CustomerInvoiceID       = _custinvoice.CustomerInvoiceID;
                            _detail.ConsignmentNo           = e_details.ConsignmentNo;
                            _detail.InScanID = e_details.InScanID;
                            //_detail.StatusPaymentMode = e_details.StatusPaymentMode;
                            _detail.FreightCharge = e_details.FreightCharge;
                            _detail.CustomsCharge = e_details.CustomsCharge;
                            _detail.OtherCharge   = e_details.OtherCharge;
                            _detail.DocCharge     = e_details.DocCharge;
                            _detail.NetValue      = e_details.TotalCharges;
                            db.CustomerInvoiceDetails.Add(_detail);
                            db.SaveChanges();

                            //inscan invoice modified
                            InScanMaster _inscan = db.InScanMasters.Find(e_details.InScanID);
                            _inscan.InvoiceID       = _custinvoice.CustomerInvoiceID;
                            db.Entry(_inscan).State = EntityState.Modified;
                            db.SaveChanges();

                            RevenueUpdateMaster _revenueupdate = db.RevenueUpdateMasters.Where(cc => cc.InScanID == e_details.InScanID).FirstOrDefault();
                            var revenuedetails = db.RevenueUpdateDetails.Where(cc => cc.MasterID == _revenueupdate.ID && cc.InvoiceId == null).ToList();
                            foreach (var revdetail in revenuedetails)
                            {
                                revdetail.InvoiceId       = _custinvoice.CustomerInvoiceID;
                                db.Entry(revdetail).State = EntityState.Modified;
                                db.SaveChanges();
                            }
                            _revenueupdate.InvoiceId       = _custinvoice.CustomerInvoiceID;
                            db.Entry(_revenueupdate).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                    }
                }

                //Accounts Posting
                PickupRequestDAO _dao = new PickupRequestDAO();
                _dao.GenerateInvoicePosting(_custinvoice.CustomerInvoiceID);

                TempData["SuccessMsg"] = "You have successfully Saved the Customer Invoice";
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Exemple #23
0
        public IHttpActionResult PostTeacher(TeacherModel teachermodel, string newlogo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            User teacherold = db.Users.Where(s => s.Email == teachermodel.Email).FirstOrDefault();

            if (teacherold != null)
            {
                return(Json("Email already exists"));
            }
            else
            {
                if (newlogo != "")
                {
                    teachermodel.Photo = newlogo;
                }

                try
                {
                    User superadminuser = db.Users.Find(1);

                    User user = new User();
                    user.Email        = teachermodel.Email;
                    user.Password     = teachermodel.Password;
                    user.CanCreate    = false;
                    user.CanEdit      = false;
                    user.CanDelete    = false;
                    user.CanPrint     = false;
                    user.Status       = false;
                    user.CreatedOn    = DateTime.Now;
                    user.LastLoggedOn = null;
                    db.Users.Add(user);
                    db.SaveChanges();

                    Role     role      = db.Roles.Where(r => r.Name == "Teacher").FirstOrDefault();
                    UserRole userroles = new UserRole();
                    userroles.UserID = user.UserID;
                    userroles.RoleID = role.RoleID;
                    db.UserRoles.Add(userroles);
                    db.SaveChanges();

                    Teacher teacher = new Teacher();
                    teacher.Name         = teachermodel.Name;
                    teacher.HouseNo      = teachermodel.HouseNo;
                    teacher.BuildingName = teachermodel.BuildingName;
                    teacher.Street       = teachermodel.Street;
                    teacher.Area         = teachermodel.Area;
                    teacher.Location     = teachermodel.Location;
                    teacher.CityID       = teachermodel.CityID;
                    teacher.CountryID    = teachermodel.CountryID;
                    teacher.PinCode      = teachermodel.PinCode;
                    teacher.Landline     = teachermodel.Landline;
                    teacher.Mobile       = teachermodel.Mobile;
                    teacher.Photo        = teachermodel.Photo;
                    teacher.SchoolID     = teachermodel.SchoolID;
                    teacher.UserID       = user.UserID;
                    teacher.Status       = teachermodel.Status;
                    db.Teachers.Add(teacher);
                    db.SaveChanges();

                    user.Status          = true;
                    db.Entry(user).State = EntityState.Modified;
                    db.SaveChanges();

                    string To = teachermodel.Email, WebsiteUrl, Ssl, UserID, Password, SMTPPort, Host;
                    CommanFunctions.AppSettings(out WebsiteUrl, out Ssl, out UserID, out Password, out SMTPPort, out Host);
                    string subject = "New Teacher Created";
                    string body    = "Hi,";
                    body += "<br/> Teacher was created. Please login using these credentials, and update teacher profile. <br/> Login email : " + teachermodel.Email;
                    body += "<br/> Login password : "******"<br/> <br/> ----------------------";
                    body += "<br/> Admin";
                    body += "<br/> <a href=" + WebsiteUrl + ">" + WebsiteUrl + "</a>";
                    try { CommanFunctions.SendEmail(UserID, subject, body, superadminuser.Email, To, Ssl, UserID, Password, SMTPPort, Host); }
                    catch { }
                }
                catch
                {
                    return(Json("Error in creating"));
                }
            }

            return(Json("Created Successfully"));
        }
Exemple #24
0
        public IHttpActionResult PostStudent(StudentModel studentmodel, string newlogo, int academicyearid)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            User studentold = db.Users.Where(s => s.Email == studentmodel.Email).FirstOrDefault();

            if (studentold != null)
            {
                return(Json("Email already exists"));
            }
            else
            {
                if (newlogo != "")
                {
                    studentmodel.Photo = newlogo;
                }

                try
                {
                    User superadminuser = db.Users.Find(1);

                    User user = new User();
                    user.Email        = studentmodel.Email;
                    user.Password     = studentmodel.Password;
                    user.CanCreate    = false;
                    user.CanEdit      = false;
                    user.CanDelete    = false;
                    user.CanPrint     = false;
                    user.Status       = false;
                    user.CreatedOn    = DateTime.Now;
                    user.LastLoggedOn = null;
                    db.Users.Add(user);
                    db.SaveChanges();


                    Role     role      = db.Roles.Where(r => r.Name == "Student").FirstOrDefault();
                    UserRole userroles = new UserRole();
                    userroles.UserID = user.UserID;
                    userroles.RoleID = role.RoleID;
                    db.UserRoles.Add(userroles);
                    db.SaveChanges();

                    Student student = new Student();
                    student.Name      = studentmodel.Name;
                    student.Mobile    = studentmodel.Mobile;
                    student.IdCard    = studentmodel.IdCard;
                    student.ClassID   = studentmodel.ClassID;
                    student.SectionID = studentmodel.SectionID;

                    student.Photo    = studentmodel.Photo;
                    student.SchoolID = studentmodel.SchoolID;
                    student.UserID   = user.UserID;
                    student.Status   = studentmodel.Status;
                    db.Students.Add(student);
                    db.SaveChanges();

                    School school = db.Schools.Find(studentmodel.SchoolID);

                    studentmodel.IdCard     = "" + school.ShortName + "-" + student.StudentID.ToString("D" + 6);
                    db.Entry(student).State = EntityState.Modified;
                    db.SaveChanges();

                    user.Status          = true;
                    db.Entry(user).State = EntityState.Modified;
                    db.SaveChanges();

                    string To = studentmodel.Email, WebsiteUrl, Ssl, UserID, Password, SMTPPort, Host;
                    CommanFunctions.AppSettings(out WebsiteUrl, out Ssl, out UserID, out Password, out SMTPPort, out Host);
                    string subject = "New Student Created";
                    string body    = "Hi,";
                    body += "<br/> Student was created. Please login using these credentials, and update student profile. <br/> Login email : " + studentmodel.Email;
                    body += "<br/> Login password : "******"<br/> <br/> ----------------------";
                    body += "<br/> Admin";
                    body += "<br/> <a href=" + WebsiteUrl + ">" + WebsiteUrl + "</a>";
                    try { CommanFunctions.SendEmail(UserID, subject, body, superadminuser.Email, To, Ssl, UserID, Password, SMTPPort, Host); }
                    catch { }
                }
                catch
                {
                    return(Json("Error in creating"));
                }
            }

            return(Json("Created Successfully"));
        }
        // GET: RevenueUpdate
        public ActionResult Index(string pTDNo, string FromDate, string ToDate)
        {
            ViewBag.Employee            = db.EmployeeMasters.ToList();
            ViewBag.PickupRequestStatus = db.PickUpRequestStatus.ToList();

            int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int depotId  = Convert.ToInt32(Session["CurrentDepotID"].ToString());

            DateTime pFromDate;
            DateTime pToDate;
            string   TDNo = "";

            if (TDNo == null)
            {
                TDNo = "";
            }
            else
            {
                TDNo = pTDNo;
            }
            if (FromDate == null || ToDate == null)
            {
                pFromDate = CommanFunctions.GetFirstDayofMonth().Date;           //.AddDays(-1); // FromDate = DateTime.Now;
                pToDate   = CommanFunctions.GetLastDayofMonth().Date.AddDays(1); // // ToDate = DateTime.Now;
            }
            else
            {
                pFromDate = Convert.ToDateTime(FromDate);//.AddDays(-1);
                pToDate   = Convert.ToDateTime(ToDate).AddDays(1);
            }


            List <CostUpdateMasterVM> lst = new List <CostUpdateMasterVM>();

            if (TDNo == "" || TDNo == null)
            {
                lst = (from d in db.CostUpdateMasters
                       join c in db.TruckDetails on d.TruckDetailID equals c.TruckDetailID
                       where (d.EntryDate >= pFromDate && d.EntryDate < pToDate)
                       select new CostUpdateMasterVM
                {
                    ID = d.ID,
                    EntryDate = d.EntryDate,
                    TDDate = c.TDDate,
                    TDNo = c.ReceiptNo,
                    DriverName = c.DriverName,
                    RegNo = c.RegNo
                }).ToList();
            }
            else
            {
                lst = (from d in db.CostUpdateMasters
                       join c in db.TruckDetails on d.TruckDetailID equals c.TruckDetailID
                       where (c.ReceiptNo == TDNo)
                       select new CostUpdateMasterVM
                {
                    ID = d.ID,
                    EntryDate = d.EntryDate,
                    TDDate = c.TDDate,
                    TDNo = c.ReceiptNo,
                    DriverName = c.DriverName,
                    RegNo = c.RegNo
                }).ToList();
            }

            lst.ForEach(d => d.Amount = (from s in db.CostUpdateDetails where s.MasterID == d.ID select s).ToList().Sum(a => a.Amount));
            lst = lst.OrderByDescending(cc => cc.TDDate).ToList();

            ViewBag.FromDate = pFromDate.Date.ToString("dd-MM-yyyy");
            ViewBag.ToDate   = pToDate.Date.AddDays(-1).ToString("dd-MM-yyyy");
            ViewBag.TDNo     = TDNo;

            ViewBag.FromDate = pFromDate.Date.ToString("dd-MM-yyyy");
            ViewBag.ToDate   = pToDate.Date.AddDays(-1).ToString("dd-MM-yyyy");

            return(View(lst));
        }
Exemple #26
0
        public ActionResult Create(DebitNoteVM v)
        {
            var             userid   = Convert.ToInt32(Session["UserID"]);
            int             BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            AcJournalMaster ajm      = new AcJournalMaster();
            int             fyearid  = Convert.ToInt32(Session["fyearid"].ToString());

            if (v.DebitNoteId > 0)
            {
                ajm = db.AcJournalMasters.Find(v.AcJournalID);
                var ajmd = db.AcJournalDetails.Where(cc => cc.AcJournalID == v.AcJournalID).ToList();
                db.AcJournalDetails.RemoveRange(ajmd);
                db.AcJournalMasters.Remove(ajm);
                db.SaveChanges();
                v.AcJournalID = 0;
            }
            if (v.AcJournalID == 0)
            {
                int acjm = 0;
                acjm = (from c in db.AcJournalMasters orderby c.AcJournalID descending select c.AcJournalID).FirstOrDefault();

                ajm.AcJournalID       = acjm + 1;
                ajm.AcCompanyID       = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
                ajm.BranchID          = Convert.ToInt32(Session["CurrentBranchID"].ToString());
                ajm.AcFinancialYearID = fyearid;
                ajm.PaymentType       = 1;
                var customer = db.SupplierMasters.Find(v.SupplierID).SupplierName;
                ajm.Remarks      = v.Remarks; // + " DN: for " + customer + " invoice : " + v.InvoiceNo;
                ajm.StatusDelete = false;
                ajm.VoucherNo    = AccountsDAO.GetMaxVoucherNo(v.TransType, fyearid);
                ajm.TransDate    = v.Date;
                ajm.TransType    = 1;
                ajm.VoucherType  = v.TransType;

                db.AcJournalMasters.Add(ajm);
                db.SaveChanges();
            }

            AcJournalDetail a = new AcJournalDetail();

            a = db.AcJournalDetails.Where(cc => cc.AcJournalID == ajm.AcJournalID && cc.Amount > 0).FirstOrDefault();
            if (a == null)
            {
                a = new AcJournalDetail();
                a.AcJournalDetailID = 0;
            }
            if (a.AcJournalDetailID == 0)
            {
                int maxacj = (from c in db.AcJournalDetails orderby c.AcJournalDetailID descending select c.AcJournalDetailID).FirstOrDefault();
                a.AcJournalDetailID = maxacj + 1;
                a.AcJournalID       = ajm.AcJournalID;
                //var customercon = db.AcHeads.Where(cc => cc.AcHead1 == "Supplier Control A/c ( Cr)").FirstOrDefault();
                a.AcHeadID = 337; //customercon.AcHeadID; ;
            }

            a.Amount   = v.Amount;
            a.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            a.Remarks  = v.Remarks;

            if (a.ID == 0)
            {
                db.AcJournalDetails.Add(a);
                db.SaveChanges();
            }
            else
            {
                db.Entry(a).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
            }
            foreach (var detail in v.Details)
            {
                AcJournalDetail b = new AcJournalDetail();
                b = db.AcJournalDetails.Where(cc => cc.AcJournalID == ajm.AcJournalID && cc.Amount < 0).FirstOrDefault();
                if (b == null)
                {
                    b = new AcJournalDetail();
                    b.AcJournalDetailID = 0;
                }
                if (b.AcJournalDetailID == 0)
                {
                    int maxacj = 0;
                    maxacj = (from c in db.AcJournalDetails orderby c.AcJournalDetailID descending select c.AcJournalDetailID).FirstOrDefault();

                    b.AcJournalDetailID = maxacj + 1;
                    b.AcJournalID       = ajm.AcJournalID;
                }
                b.AcHeadID = v.AcHeadID;
                if (v.TransType == "DN")
                {
                    b.Amount = -1 * detail.Amount;
                }
                else
                {
                    b.Amount = detail.Amount;
                }
                b.BranchID = Convert.ToInt32(Session["CurrentBranchID"].ToString());
                b.Remarks  = detail.Remarks;
                if (b.ID == 0)
                {
                    db.AcJournalDetails.Add(b);
                    db.SaveChanges();
                }
                else
                {
                    db.Entry(b).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
            }


            DebitNote d = new DebitNote();

            if (v.DebitNoteId == 0)
            {
                int maxid = 0;

                var data = (from c in db.DebitNotes orderby c.DebitNoteID descending select c).FirstOrDefault();

                if (data == null)
                {
                    maxid = 1;
                }
                else
                {
                    maxid = data.DebitNoteID + 1;
                }
                d.CreatedBy   = userid;
                d.CreatedDate = CommanFunctions.GetCurrentDateTime();
                d.DebitNoteID = maxid;
                d.DebitNoteNo = AccountsDAO.GetMaxDebiteNoteNo(fyearid);
            }
            else
            {
                d = db.DebitNotes.Find(v.DebitNoteId);
                var det = db.DebitNoteDetails.Where(cc => cc.DebitNoteID == v.DebitNoteId).ToList();
                if (det != null)
                {
                    db.DebitNoteDetails.RemoveRange(det);
                    db.SaveChanges();
                }
            }


            d.InvoiceType = v.InvoiceType;
            d.TransType   = v.TransType;
            if (v.InvoiceID != 0)
            {
                if (v.TransType == "DN")
                {
                    d.InvoiceID = v.InvoiceID;
                }
                else
                {
                    d.RecPayID = v.InvoiceID;
                }
            }
            else
            {
                d.InvoiceID = 0;
            }
            d.DebitNoteDate = v.Date;
            d.Amount        = v.Amount;
            d.AcJournalID   = ajm.AcJournalID;
            d.FYearID       = Convert.ToInt32(Session["fyearid"].ToString());
            d.AcCompanyID   = Convert.ToInt32(Session["CurrentCompanyID"].ToString());
            d.BranchID      = Convert.ToInt32(Session["CurrentBranchID"].ToString());

            d.AcHeadID   = 527;;
            d.SupplierID = v.SupplierID;

            d.ModifiedBy   = userid;
            d.ModifiedDate = CommanFunctions.GetCurrentDateTime();
            d.Remarks      = v.Remarks;
            //d.IsShipping = true;
            if (v.DebitNoteId == 0)
            {
                db.DebitNotes.Add(d);
                db.SaveChanges();
                TempData["SuccessMsg"] = "Successfully Added Debit Note";
            }
            else
            {
                db.Entry(d).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                TempData["SuccessMsg"] = "Successfully Updated Debit Note";
            }
            foreach (var detail in v.Details)
            {
                DebitNoteDetail det = new DebitNoteDetail();
                det.AcHeadID    = detail.AcHeadID;
                det.Amount      = detail.Amount;
                det.Remarks     = detail.Remarks;
                det.DebitNoteID = d.DebitNoteID;
                db.DebitNoteDetails.Add(det);
                db.SaveChanges();
            }

            return(RedirectToAction("Index", "DebitNote"));
        }
Exemple #27
0
        public ActionResult Edit(CustomerInvoiceVM model)
        {
            var userid = Convert.ToInt32(Session["UserID"]);

            if (model.CustomerInvoiceID > 0)
            {
                CustomerInvoice _custinvoice = new CustomerInvoice();
                _custinvoice                 = db.CustomerInvoices.Find(model.CustomerInvoiceID);
                _custinvoice.InvoiceDate     = model.InvoiceDate;
                _custinvoice.TaxPercent      = model.TaxPercent;
                _custinvoice.InvoiceTotal    = model.InvoiceTotal;
                _custinvoice.Remarks         = model.Remarks;
                _custinvoice.ModifiedBy      = userid;
                _custinvoice.ModifiedDate    = CommanFunctions.GetCurrentDateTime();
                db.Entry(_custinvoice).State = EntityState.Modified;
                db.SaveChanges();

                List <CustomerInvoiceDetailVM> e_Details = model.CustomerInvoiceDetailsVM; //  Session["InvoiceListing"] as List<CustomerInvoiceDetailVM>;

                model.CustomerInvoiceDetailsVM = e_Details;

                if (model.CustomerInvoiceDetailsVM != null)
                {
                    foreach (var e_details in model.CustomerInvoiceDetailsVM)
                    {
                        if (e_details.CustomerInvoiceDetailID == 0 && e_details.AWBChecked)
                        {
                            CustomerInvoiceDetail _detail = new CustomerInvoiceDetail();
                            _detail.CustomerInvoiceDetailID = db.CustomerInvoiceDetails.Select(x => x.CustomerInvoiceDetailID).DefaultIfEmpty(0).Max() + 1;
                            _detail.CustomerInvoiceID       = _custinvoice.CustomerInvoiceID;
                            _detail.ConsignmentNo           = e_details.ConsignmentNo;
                            _detail.InScanID = e_details.InScanID;
                            //_detail.StatusPaymentMode = e_details.StatusPaymentMode;
                            _detail.FreightCharge = e_details.FreightCharge;
                            _detail.CustomsCharge = e_details.CustomsCharge;
                            _detail.DocCharge     = e_details.DocCharge;
                            _detail.OtherCharge   = e_details.OtherCharge;
                            db.CustomerInvoiceDetails.Add(_detail);
                            db.SaveChanges();

                            //inscan invoice modified
                            InScanMaster _inscan = db.InScanMasters.Find(e_details.InScanID);
                            _inscan.InvoiceID       = _custinvoice.CustomerInvoiceID;
                            db.Entry(_inscan).State = EntityState.Modified;
                            db.SaveChanges();

                            RevenueUpdateMaster _revenueupdate = db.RevenueUpdateMasters.Where(cc => cc.InScanID == e_details.InScanID).FirstOrDefault();
                            _revenueupdate.InvoiceId       = _custinvoice.CustomerInvoiceID;
                            db.Entry(_revenueupdate).State = EntityState.Modified;
                            db.SaveChanges();
                        }
                        else if (e_details.CustomerInvoiceDetailID == 0 && e_details.AWBChecked == false)
                        {
                            //CustomerInvoiceDetail _detail = new CustomerInvoiceDetail();
                            //_detail = db.CustomerInvoiceDetails.Find(e_details.CustomerInvoiceID);
                            //_detail.CourierCharge = e_details.CourierCharge;
                            //_detail.CustomCharge = e_details.CustomCharge;
                            //_detail.OtherCharge = e_details.OtherCharge;
                            //db.CustomerInvoiceDetails.Add(_detail);
                            //db.SaveChanges();

                            ////inscan invoice modified
                            //InScanMaster _inscan = db.InScanMasters.Find(e_details.InscanID);
                            //_inscan.InvoiceID = _custinvoice.CustomerInvoiceID;
                            //db.Entry(_inscan).State = System.Data.EntityState.Modified;
                            //db.SaveChanges();
                        }
                        else if (e_details.CustomerInvoiceDetailID > 0 && e_details.AWBChecked == false)
                        {
                            CustomerInvoiceDetail _detail = new CustomerInvoiceDetail();
                            _detail = db.CustomerInvoiceDetails.Find(e_details.CustomerInvoiceDetailID);
                            db.CustomerInvoiceDetails.Remove(_detail);
                            db.SaveChanges();
                            ////inscan invoice modified
                            InScanMaster _inscan = db.InScanMasters.Find(e_details.InScanID);
                            _inscan.InvoiceID       = null;
                            db.Entry(_inscan).State = EntityState.Modified;
                            db.SaveChanges();

                            RevenueUpdateMaster        _revenueupdate       = db.RevenueUpdateMasters.Where(cc => cc.InScanID == e_details.InScanID).FirstOrDefault();
                            List <RevenueUpdateDetail> revenueUpdateDetails = db.RevenueUpdateDetails.Where(cc => cc.MasterID == _revenueupdate.ID).ToList();
                            foreach (RevenueUpdateDetail item in revenueUpdateDetails)
                            {
                                item.InvoiceId       = null;
                                db.Entry(item).State = EntityState.Modified;
                                db.SaveChanges();
                            }
                            //_revenueupdate.InvoiceId = null;
                            //db.Entry(_revenueupdate).State = EntityState.Modified;
                            //db.SaveChanges();
                        }
                    }
                }
                //Accounts Posting
                PickupRequestDAO _dao = new PickupRequestDAO();
                _dao.GenerateInvoicePosting(_custinvoice.CustomerInvoiceID);

                TempData["SuccessMsg"] = "You have successfully Updated the Customer Invoice";
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
        public IHttpActionResult PostSchool(SchoolModel schoolmodel, string newlogo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            User schoolold = db.Users.Where(s => s.Email == schoolmodel.Email).FirstOrDefault();

            if (schoolold != null)
            {
                return(Json("Email already exists"));
            }
            else
            {
                if (newlogo != "")
                {
                    schoolmodel.Logo = newlogo;
                }

                try
                {
                    apiheaderdata apidata        = APIAuthorizeAttribute.GetAuthorize(Request.Headers.GetValues("Token").First());
                    User          superadminuser = db.Users.Find(1);

                    User user = new User();
                    user.Email        = schoolmodel.Email;
                    user.Password     = schoolmodel.Password;
                    user.CanCreate    = false;
                    user.CanEdit      = false;
                    user.CanDelete    = false;
                    user.CanPrint     = false;
                    user.Status       = false;
                    user.CreatedOn    = DateTime.Now;
                    user.LastLoggedOn = null;
                    db.Users.Add(user);
                    db.SaveChanges();

                    Role     role      = db.Roles.Where(r => r.Name == "SchoolAdmin").FirstOrDefault();
                    UserRole userroles = new UserRole();
                    userroles.UserID = user.UserID;
                    userroles.RoleID = role.RoleID;
                    db.UserRoles.Add(userroles);
                    db.SaveChanges();

                    School school = new School();
                    school.Name                  = schoolmodel.Name;
                    school.ShortName             = schoolmodel.ShortName;
                    school.HouseNo               = schoolmodel.HouseNo;
                    school.BuildingName          = schoolmodel.BuildingName;
                    school.Street                = schoolmodel.Street;
                    school.Area                  = schoolmodel.Area;
                    school.Location              = schoolmodel.Location;
                    school.CityID                = schoolmodel.CityID;
                    school.CountryID             = schoolmodel.CountryID;
                    school.PinCode               = schoolmodel.PinCode;
                    school.Landline              = schoolmodel.Landline;
                    school.Mobile                = schoolmodel.Mobile;
                    school.Website               = schoolmodel.Website;
                    school.RegNo                 = schoolmodel.RegNo;
                    school.Logo                  = schoolmodel.Logo;
                    school.CompanyAcademicYearID = schoolmodel.CompanyAcademicYearID;
                    school.Principal             = schoolmodel.Principal;
                    school.UserID                = user.UserID;
                    CompanyAcademicYear companyacademicyear = db.CompanyAcademicYears.Include(c => c.CurrentCompany).Include(c => c.CurrentAcademicYear).Where(c => c.AcademicYearID == apidata.AcademicYearID).FirstOrDefault();
                    school.CompanyAcademicYearID = companyacademicyear.CompanyAcademicYearID;
                    school.Status = schoolmodel.Status;
                    db.Schools.Add(school);
                    db.SaveChanges();

                    user.Status          = true;
                    db.Entry(user).State = EntityState.Modified;
                    db.SaveChanges();

                    string To = schoolmodel.Email, WebsiteUrl, Ssl, UserID, Password, SMTPPort, Host;
                    CommanFunctions.AppSettings(out WebsiteUrl, out Ssl, out UserID, out Password, out SMTPPort, out Host);
                    string subject = "New School Created";
                    string body    = "Hi,";
                    body += "<br/> School was created. Please login using these credentials, and update school profile. <br/> Login email : " + schoolmodel.Email;
                    body += "<br/> Login password : "******"<br/> <br/> ----------------------";
                    body += "<br/> Admin";
                    body += "<br/> <a href=" + WebsiteUrl + ">" + WebsiteUrl + "</a>";
                    try { CommanFunctions.SendEmail(UserID, subject, body, superadminuser.Email, To, Ssl, UserID, Password, SMTPPort, Host); }
                    catch { }
                }
                catch
                {
                    return(Json("Error in creating"));
                }
            }

            return(Json("Created Successfully"));
        }
Exemple #29
0
        public ActionResult Create(int id = 0)
        {
            //List<Invoices> lst = new List<Invoices>();
            //ViewBag.Supplier = db.SupplierMasters.OrderBy(x => x.SupplierName).ToList();
            //ViewBag.AcHead = db.AcHeads.OrderBy(x => x.AcHead1).ToList();
            //ViewBag.Invoice = lst;
            //return View();

            int fyearid = Convert.ToInt32(Session["fyearid"].ToString());

            ViewBag.Supplier = db.SupplierMasters.OrderBy(x => x.SupplierName).ToList();
            ViewBag.AcHead   = db.AcHeads.OrderBy(x => x.AcHead1).ToList();

            if (id == 0)
            {
                ViewBag.Title = "DEBIT NOTE/SUPPLIER JOURNAL";
                DebitNoteVM vm = new DebitNoteVM();
                vm.DebitNoteNo = AccountsDAO.GetMaxDebiteNoteNo(fyearid);
                vm.Date        = CommanFunctions.GetLastDayofMonth().Date;
                vm.AcHeadID    = 337;
                vm.TransType   = "";
                //vm.AmountType = "1";
                //vm.AcDetailAmountType = "0";
                List <DebitNoteDetailVM> list = new List <DebitNoteDetailVM>();
                vm.Details = list;

                Session["DebitNoteDetail"] = list;
                return(View(vm));
            }
            else
            {
                ViewBag.Title = "DEBIT NOTE/SUPPLIER JOURNAL - Modify";
                DebitNoteVM vm = new DebitNoteVM();
                var         v  = db.DebitNotes.Find(id);
                vm.DebitNoteId = v.DebitNoteID;
                vm.Date        = v.DebitNoteDate;
                vm.AcJournalID = Convert.ToInt32(v.AcJournalID);
                vm.DebitNoteNo = v.DebitNoteNo;
                vm.SupplierID  = Convert.ToInt32(v.SupplierID);
                vm.AcHeadID    = Convert.ToInt32(v.AcHeadID);
                vm.Amount      = Convert.ToDecimal(v.Amount);
                vm.InvoiceType = v.InvoiceType;
                vm.Remarks     = v.Remarks;
                vm.TransType   = v.TransType;
                vm.InvoiceID   = Convert.ToInt32(v.InvoiceID);
                if (v.RecPayID != null && v.RecPayID != 0)
                {
                    vm.RecPayID = Convert.ToInt32(v.RecPayID);
                }
                else
                {
                    vm.RecPayID = 0;
                }

                var detaillist = (from c in db.DebitNoteDetails join d in db.AcHeads on c.AcHeadID equals d.AcHeadID where c.DebitNoteID == v.DebitNoteID select new DebitNoteDetailVM {
                    AcHeadID = c.AcHeadID, AcHeadName = d.AcHead1, Amount = c.Amount, Remarks = c.Remarks
                }).ToList();
                vm.Details = detaillist;
                Session["DebitNoteDetail"] = detaillist;

                SetTradeInvoiceOfSupplier(vm.SupplierID, 0, vm.DebitNoteId, vm.TransType);
                List <CustomerTradeReceiptVM> lst = (List <CustomerTradeReceiptVM>)Session["SupplierInvoice"];

                if (v.TransType == "DN")
                {
                    if (v.InvoiceType == "TR")
                    {
                        var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "TR").FirstOrDefault();
                        //var invoice = db.SupplierInvoices.Find(vm.InvoiceID);
                        if (invoice != null)
                        {
                            vm.InvoiceNo     = invoice.InvoiceNo;
                            vm.InvoiceDate   = invoice.DateTime;
                            vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount);
                            vm.AmountPaid    = Convert.ToDecimal(invoice.AmountReceived);
                        }
                    }
                    else if (v.InvoiceType == "OP")
                    {
                        var invoice1 = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "OP").FirstOrDefault();
                        //var invoice1 = db.AcOPInvoiceDetails.Where(cc => cc.AcOPInvoiceDetailID == vm.InvoiceID).FirstOrDefault();
                        if (invoice1 != null)
                        {
                            vm.InvoiceNo     = invoice1.InvoiceNo;
                            vm.InvoiceDate   = invoice1.DateTime;
                            vm.InvoiceAmount = Convert.ToDecimal(invoice1.InvoiceAmount);
                            vm.AmountPaid    = Convert.ToDecimal(invoice1.AmountReceived);
                        }
                    }
                }
                else if (v.RecPayID != null && v.RecPayID != 0 && v.TransType == "SJ")
                {
                    vm.InvoiceID   = Convert.ToInt32(v.RecPayID);
                    vm.InvoiceType = v.InvoiceType;
                    vm.ForInvoice  = true;

                    if (v.InvoiceType == "TR")
                    {
                        var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "TR").FirstOrDefault();
                        if (invoice != null)
                        {
                            vm.InvoiceNo     = invoice.InvoiceNo;
                            vm.InvoiceDate   = invoice.DateTime;
                            vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount);
                            vm.AmountPaid    = Convert.ToDecimal(invoice.AmountReceived);
                        }
                    }
                    else if (v.InvoiceType == "OP")
                    {
                        var invoice = lst.Where(cc => cc.SalesInvoiceID == vm.InvoiceID && cc.InvoiceType == "OP").FirstOrDefault();
                        vm.InvoiceNo     = invoice.InvoiceNo;
                        vm.InvoiceDate   = invoice.DateTime;
                        vm.InvoiceAmount = Convert.ToDecimal(invoice.InvoiceAmount);
                        vm.AmountPaid    = Convert.ToDecimal(invoice.AmountReceived);
                    }
                }
                else
                {
                    vm.ForInvoice = false;
                }
                //SetTradeInvoiceOfCustomer(vm.CustomerID, 0, vm.CreditNoteID);
                vm.Date = Convert.ToDateTime(v.DebitNoteDate);

                return(View(vm));
            }
        }
        public ActionResult Index(int?StatusId, string FromDate, string ToDate)
        {
            ViewBag.Employee            = db.EmployeeMasters.ToList();
            ViewBag.PickupRequestStatus = db.PickUpRequestStatus.ToList();

            int branchid = Convert.ToInt32(Session["CurrentBranchID"].ToString());
            int depotId  = Convert.ToInt32(Session["CurrentDepotID"].ToString());

            DateTime pFromDate;
            DateTime pToDate;
            int      pStatusId = 0;

            if (StatusId == null)
            {
                pStatusId = 0;
            }
            else
            {
                pStatusId = Convert.ToInt32(StatusId);
            }
            if (FromDate == null || ToDate == null)
            {
                pFromDate = CommanFunctions.GetFirstDayofMonth().Date;           //.AddDays(-1); // FromDate = DateTime.Now;
                pToDate   = CommanFunctions.GetLastDayofMonth().Date.AddDays(1); // // ToDate = DateTime.Now;
            }
            else
            {
                pFromDate = Convert.ToDateTime(FromDate);//.AddDays(-1);
                pToDate   = Convert.ToDateTime(ToDate).AddDays(1);
            }

            // List<PickupRequestVM> lst = (from c in db.CustomerEnquiries join t1 in db.EmployeeMasters on c.CollectedEmpID equals t1.EmployeeID join t2 in db.EmployeeMasters on c.EmployeeID equals t2.EmployeeID select new PickupRequestVM { EnquiryID = c.EnquiryID, EnquiryDate = c.EnquiryDate, Consignor = c.Consignor, Consignee = c.Consignee, eCollectedBy = t1.EmployeeName, eAssignedTo = t2.EmployeeName,AWBNo=c.AWBNo }).ToList();

            //List<PickupRequestVM> lst = (from c in db.CustomerEnquiries
            //            join status in db.PickUpRequestStatus on c.PickupRequestStatusId equals status.Id
            //            join pet in db.EmployeeMasters on c.CollectedEmpID equals pet.EmployeeID into gj
            //            from subpet in gj.DefaultIfEmpty()
            //            join pet1 in db.EmployeeMasters on c.EmployeeID equals  pet1.EmployeeID into gj1
            //            from subpet1 in gj1.DefaultIfEmpty()
            //            where  c.EnquiryDate >=pFromDate &&  c.EnquiryDate <=pToDate
            //            select new PickupRequestVM { EnquiryID = c.EnquiryID, EnquiryNo=c.EnquiryNo, EnquiryDate = c.EnquiryDate, Consignor = c.Consignor, Consignee = c.Consignee, eCollectedBy =subpet.EmployeeName ?? string.Empty, eAssignedTo = subpet1.EmployeeName ?? string.Empty , AWBNo = c.AWBNo ,PickupRequestStatus=status.PickRequestStatus }).ToList();

            int Customerid = 0;

            if (Session["UserType"].ToString() == "Customer")
            {
                Customerid = Convert.ToInt32(Session["CustomerId"].ToString());
            }
            List <PickupRequestVM> lst = (from c in db.InScanMasters
                                          join statustype in db.tblStatusTypes on c.StatusTypeId equals statustype.ID
                                          join status in db.CourierStatus on c.CourierStatusID equals status.CourierStatusID
                                          join pet in db.EmployeeMasters on c.PickedUpEmpID equals pet.EmployeeID into gj
                                          from subpet in gj.DefaultIfEmpty()
                                          join pet1 in db.EmployeeMasters on c.AssignedEmployeeID equals pet1.EmployeeID into gj1
                                          from subpet1 in gj1.DefaultIfEmpty()
                                          where c.BranchID == branchid && c.IsEnquiry == true && (c.PickupRequestDate >= pFromDate && c.PickupRequestDate < pToDate) && (c.CourierStatusID == pStatusId || pStatusId == 0) &&
                                          c.IsDeleted == false &&
                                          (c.CustomerID == Customerid || Customerid == 0)
                                          orderby c.PickupRequestDate descending
                                          select new PickupRequestVM {
                PickupRequestStatusId = c.CourierStatusID, EnquiryID = c.InScanID, EnquiryNo = c.EnquiryNo, EnquiryDate = c.PickupRequestDate, Consignor = c.Consignor, Consignee = c.Consignee, eCollectedBy = subpet.EmployeeName ?? string.Empty, eAssignedTo = subpet1.EmployeeName ?? string.Empty, AWBNo = c.ConsignmentNo, PickupRequestStatus = status.CourierStatus, ShipmentType = statustype.Name
            }).ToList();

            //ViewBag.FromDate = pFromDate.Date.AddDays(1).ToString("dd-MM-yyyy");
            ViewBag.FromDate            = pFromDate.Date.ToString("dd-MM-yyyy");
            ViewBag.ToDate              = pToDate.Date.AddDays(-1).ToString("dd-MM-yyyy");
            ViewBag.PickupRequestStatus = db.CourierStatus.Where(cc => cc.StatusTypeID == 1).ToList();
            ViewBag.StatusId            = StatusId;
            return(View(lst));
        }