Exemplo n.º 1
0
        public int AddFlats(int TotalFloor, int FlatOrder, List <int> FlatNo, List <bool> PreIncrement, List <PLCModel> pmodel, string username, int towerID, string FltType, string FltTSize)
        {
            PLCService pservice = new PLCService();
            int        plcCount = pservice.GetPLCCount();

            using (REMSDBEntities context = new REMSDBEntities())
            {
                try
                {
                    for (int i = 1; i <= TotalFloor; i++)
                    {
                        int   kk  = 0;
                        Floor flo = new Floor();
                        flo.CrBy      = username; flo.CrDate = DateTime.Now;
                        flo.TowerID   = towerID;
                        flo.FloorName = i.ToString();
                        flo.FloorNo   = i;
                        context.Floors.Add(flo);
                        context.SaveChanges();
                        int jj = 0;
                        foreach (int flat in FlatNo)
                        {
                            int  fno = GenFlatNo(i, flat, PreIncrement[jj]);
                            Flat fl  = new Flat();
                            fl.FlatOrder    = FlatOrder;
                            fl.FlatNo       = fno.ToString();
                            fl.FlatName     = fno.ToString();
                            fl.FloorID      = flo.FloorID;
                            fl.FlatType     = FltType;
                            fl.FlatSizeUnit = "SqFt";
                            fl.FlatSize     = Convert.ToDecimal(FltTSize);
                            fl.Status       = "Available";
                            context.Flats.Add(fl);
                            context.SaveChanges();

                            for (int k = 0; k <= plcCount - 1; k++)
                            {
                                var pl = pmodel[kk];
                                if (pl.PLCID != 0)
                                {
                                    FlatPLC fpcl = new FlatPLC();
                                    fpcl.CrDate = DateTime.Now;
                                    fpcl.FlatID = fl.FlatID;
                                    fpcl.PLCID  = pl.PLCID;
                                    context.FlatPLCs.Add(fpcl);
                                    context.SaveChanges();
                                }
                                kk++;
                            }
                            jj++;
                        }
                    }
                    return(1);
                }
                catch (Exception ex)
                {
                    return(0);
                }
            }
        }
Exemplo n.º 2
0
 public string UpdateAssuredCheque(string asid, string chequeNo, string chequeDate, string userName)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         if (chequeDate != null && chequeDate != "")
         {
             DateTimeFormatInfo dtinfo = new DateTimeFormatInfo();
             dtinfo.DateSeparator    = "/";
             dtinfo.ShortDatePattern = "dd/MM/yyyy";
             int      id    = Convert.ToInt32(asid);
             DateTime dt    = Convert.ToDateTime(chequeDate, dtinfo);
             var      model = context.AssuredReturns.Where(rtn => rtn.AssuredReturnID == id).FirstOrDefault();
             model.ChequeNo             = chequeNo;
             model.ChequeDate           = dt;
             model.Status               = "Updated";
             model.ModifyBy             = userName;
             model.ModifyDate           = DateTime.Now;
             context.Entry(model).State = EntityState.Modified;
             int i = context.SaveChanges();
             if (i >= 1)
             {
                 return(model.SaleID.Value.ToString());
             }
             else
             {
                 return("No");
             }
         }
     }
     return("No");
 }
Exemplo n.º 3
0
 public string UpdateAssuredChequeAll(string[] chequeNos, string[] chequeDates, string[] aSids, string userName)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         string[] cno   = chequeNos;
         string[] cdate = chequeDates;
         string[] asid  = aSids;
         string   rmsg  = "No";
         for (int i = 0; i < cno.Length; i++)
         {
             if (cno[i] != "" && cdate[i] != "")
             {
                 DateTimeFormatInfo dtinfo = new DateTimeFormatInfo();
                 dtinfo.DateSeparator    = "/";
                 dtinfo.ShortDatePattern = "dd/MM/yyyy";
                 int      id    = Convert.ToInt32(asid[i]);
                 DateTime dt    = Convert.ToDateTime(cdate[i], dtinfo);
                 var      model = context.AssuredReturns.Where(rtn => rtn.AssuredReturnID == id).FirstOrDefault();
                 model.ChequeNo             = cno[i];
                 model.ChequeDate           = dt;
                 model.Status               = "Updated";
                 model.ModifyBy             = userName;
                 model.ModifyDate           = DateTime.Now;
                 context.Entry(model).State = EntityState.Modified;
                 int ii = context.SaveChanges();
                 if (ii >= 1)
                 {
                     rmsg = model.SaleID.Value.ToString();
                 }
             }
         }
         return(rmsg);
     }
 }
Exemplo n.º 4
0
 public int AddProject(ProjectModel model)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             if (model.PossessionDateSt != null)
             {
                 model.PossessionDate = Convert.ToDateTime(model.PossessionDateSt, FormData.IndianDateFormat());
             }
             Mapper.CreateMap <ProjectModel, Project>();
             var mdl = Mapper.Map <ProjectModel, Project>(model);
             mdl.RecordStatus = 0;
             mdl.CrDate       = DateTime.Now;
             mdl.ReceiptNo    = "0";
             context.Projects.Add(mdl);
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
Exemplo n.º 5
0
        public void LogException(Exception exception)
        {
            // try-catch because database itself could be down or Request context is unknown.

            try
            {
                int?userId = null;
                try { userId = 0; }
                catch { /* do nothing */ }

                // ** Prototype pattern. the Error object has it default values initialized

                var error = new Error()
                {
                    UserName  = userId.Value.ToString(),
                    Exception = exception.GetType().FullName,
                    Message   = exception.Message,

                    Everything   = exception.ToString(),
                    IpAddress    = HttpContext.Current.Request.UserHostAddress,
                    UserAgent    = HttpContext.Current.Request.UserAgent,
                    PathAndQuery = HttpContext.Current.Request.Url == null ? "" : HttpContext.Current.Request.Url.PathAndQuery,
                    HttpReferer  = HttpContext.Current.Request.UrlReferrer == null ? "" : HttpContext.Current.Request.UrlReferrer.PathAndQuery,
                    CreatedOn    = DateTime.Now,
                    ChangedOn    = DateTime.Now
                };
                using (REMSDBEntities context = new REMSDBEntities())
                {
                    context.Errors.Add(error);
                    context.SaveChanges();
                }
                //DealSiteContext.Errors.Insert(error);
            }
            catch { /* do nothing, or send email to webmaster*/ }
        }
Exemplo n.º 6
0
 public int AddTower(Tower tower)
 {
     using (var context = new REMSDBEntities())
     {
         context.Towers.Add(tower);
         int i = context.SaveChanges();
         return(i);
     }
 }
Exemplo n.º 7
0
 public int EditTower(Tower tower)
 {
     using (var context = new REMSDBEntities())
     {
         context.Towers.Add(tower);
         context.Entry(tower).State = EntityState.Modified;
         int i = context.SaveChanges();
         return(i);
     }
 }
Exemplo n.º 8
0
 public int EditFloor(Floor floor)
 {
     using (var context = new REMSDBEntities())
     {
         context.Floors.Add(floor);
         context.Entry(floor).State = EntityState.Modified;
         int i = context.SaveChanges();
         return(i);
     }
 }
Exemplo n.º 9
0
 public int DeleteFlat(int flatid)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             FlatPLCService    fpservice = new FlatPLCService();
             FlatChargeService fcservice = new FlatChargeService();
             var model = fpservice.GetFlatPLCListByFlatID(flatid);
             foreach (var md in model)
             {
                 FlatPLC plc = new FlatPLC();
                 plc.FlatPLCID = md.FlatPLCID;
                 context.FlatPLCs.Add(plc);
                 context.Entry(plc).State = EntityState.Deleted;
                 context.SaveChanges();
             }
             var fmodel = fcservice.GetFlatChargeListByFlatID(flatid);
             foreach (var md in fmodel)
             {
                 FlatCharge plc = new FlatCharge();
                 plc.FlatChargeID = md.FlatChargeID;
                 context.FlatCharges.Add(plc);
                 context.Entry(plc).State = EntityState.Deleted;
                 context.SaveChanges();
             }
             Flat ft = new Flat();
             ft.FlatID = flatid;
             context.Flats.Add(ft);
             context.Entry(ft).State = EntityState.Deleted;
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
Exemplo n.º 10
0
 public int AddFloor(Floor floor)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             context.Floors.Add(floor);
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
 public int AddFlatTypeSize(FlatTypeSize model)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             context.FlatTypeSizes.Add(model);
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
 public int AddPlanTypeMaster(PlanTypeMaster model)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             context.PlanTypeMasters.Add(model);
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
 public int EditFlatTypeSize(FlatTypeSize model)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             context.FlatTypeSizes.Add(model);
             context.Entry(model).State = EntityState.Modified;
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
 public int DeletePlanInstallment(PlanInstallment model)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             context.PlanInstallments.Add(model);
             context.Entry(model).State = EntityState.Deleted;
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
 public int AddPlanInstallment(PlanInstallmentModel model)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             Mapper.CreateMap <PlanInstallmentModel, PlanInstallment>();
             var mdl = Mapper.Map <PlanInstallmentModel, PlanInstallment>(model);
             context.PlanInstallments.Add(mdl);
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
Exemplo n.º 16
0
 public int AddProjectType(ProjectTypeModel model)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             Mapper.CreateMap <ProjectTypeModel, ProjectType>();
             var mdl = Mapper.Map <ProjectTypeModel, ProjectType>(model);
             context.ProjectTypes.Add(mdl);
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
Exemplo n.º 17
0
 public int DeleteFloor(int floorid)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             Floor fl = new Floor();
             fl.FloorID = floorid;
             context.Floors.Add(fl);
             context.Entry(fl).State = EntityState.Deleted;
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
Exemplo n.º 18
0
 public string UpdateAssuredChequeUnClearance(string asId, string userName)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         int id    = Convert.ToInt32(asId);
         var model = context.AssuredReturns.Where(rtn => rtn.AssuredReturnID == id).FirstOrDefault();
         model.Status               = "Updated";
         model.ModifyBy             = userName;
         model.ModifyDate           = DateTime.Now;
         context.Entry(model).State = EntityState.Modified;
         int i = context.SaveChanges();
         if (i >= 1)
         {
             return(model.SaleID.Value.ToString());
         }
         else
         {
             return("No");
         }
     }
 }
Exemplo n.º 19
0
 public int DeletePLC(PLCModel model)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             Mapper.CreateMap <PLCModel, PLC>();
             var mdl = Mapper.Map <PLCModel, PLC>(model);
             context.PLCs.Add(mdl);
             context.Entry(mdl).State = EntityState.Deleted;
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
Exemplo n.º 20
0
 public int EditProject(ProjectModel model)
 {
     using (REMSDBEntities context = new REMSDBEntities())
     {
         try
         {
             Mapper.CreateMap <ProjectModel, Project>();
             var mdl = Mapper.Map <ProjectModel, Project>(model);
             context.Projects.Add(mdl);
             context.Entry(mdl).State = EntityState.Modified;
             int i = context.SaveChanges();
             return(i);
         }
         catch (Exception ex)
         {
             Helper hp = new Helper();
             hp.LogException(ex);
             return(0);
         }
     }
 }
        public string GetInstallmentByInstallId(int installmentID, string modifyDate)
        {
            DateTimeFormatInfo dtinfo = new DateTimeFormatInfo();

            dtinfo.ShortDatePattern = "dd/MM/yyyy";
            dtinfo.DateSeparator    = "/";
            DateTime dt = new DateTime();

            if (modifyDate != null && modifyDate != "")
            {
                using (REMSDBEntities context = new REMSDBEntities())
                {
                    var fl = context.FlatInstallmentDetails.Where(s => s.InstallmentID == installmentID).FirstOrDefault <FlatInstallmentDetail>();
                    fl.DueDate = dt;
                    context.SaveChanges();
                }
                return("Event Completion date updated.");
            }
            else
            {
                return("Invalid Date format.");
            }
        }
        public string SaveUsersRights(string username, string modulelist, string notinaccess)
        {
            try
            {
                REMSDBEntities context = new REMSDBEntities();
                string[]       pids    = modulelist.Split(',');
                if (pids.Length > 0)
                {
                    foreach (string pid in pids)
                    {
                        var UAM = context.UserAccesses.Where(ua => ua.UserName == username && ua.ModuleListID == pid).FirstOrDefault();
                        if (UAM == null)
                        {
                            // Insert
                            int        mid = Convert.ToInt32(pid);
                            var        Mdl = context.ModuleLists.Where(md => md.ModuleListID == mid).FirstOrDefault();
                            UserAccess us  = new UserAccess();
                            us.UserName       = username;
                            us.IsRead         = true; us.IsWrite = true;
                            us.ControllerName = Mdl.Controller;
                            us.ActionName     = Mdl.ActionName;
                            us.AssignDate     = DateTime.Now;
                            us.AssignUser     = User.Identity.Name;
                            us.ModuleListID   = pid;
                            context.UserAccesses.Add(us);
                            int i = context.SaveChanges();
                        }
                        else
                        {
                            // Update
                            UAM.IsRead     = true;
                            UAM.IsWrite    = true;
                            UAM.AssignUser = User.Identity.Name;
                            UAM.AssignDate = DateTime.Now;
                            context.UserAccesses.Add(UAM);
                            context.Entry(UAM).State = EntityState.Modified;
                            int i = context.SaveChanges();
                        }
                    }
                }
                string[] llist = notinaccess.Split(',');
                foreach (string pid in llist)
                {
                    var UAM = context.UserAccesses.Where(ua => ua.UserName == username && ua.ModuleListID == pid).FirstOrDefault();
                    if (UAM == null)
                    {
                    }
                    else
                    {
                        // Delete
                        context.UserAccesses.Add(UAM);
                        context.Entry(UAM).State = EntityState.Deleted;
                        int i = context.SaveChanges();
                    }
                }
                return("Users Access Rights Saved.");
            }

            catch (Exception ex)
            {
                hp.LogException(ex);
                return("Error!, Please try again.");
            }
        }
        public async Task <string> AddUser(UserModel model)
        {
            string[] pids = model.Property.Split(',');
            if (pids.Length > 0)
            {
                var user = new ApplicationUser()
                {
                    UserName = model.UserName, Email = model.EmailID
                };
                IdentityResult result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    Roles.AddUserToRole(model.UserName, model.RoleName);
                    //  await SignInAsync(user, isPersistent: false);
                    // Add Users Property
                    REMSDBEntities context = new REMSDBEntities();
                    foreach (string pid in pids)
                    {
                        UserProperty up = new UserProperty();
                        up.UserName   = model.UserName;
                        up.ProjectID  = Convert.ToInt32(pid);
                        up.AssignUser = User.Identity.Name;
                        up.AssignDate = DateTime.Now;
                        context.UserProperties.Add(up);
                        int i = context.SaveChanges();
                    }
                    var roleacc          = context.RoleAccesses.Where(ro => ro.RoleName == model.RoleName).ToList();
                    List <RoleAccess> ra = new List <RoleAccess>();

                    foreach (var r in roleacc)
                    {
                        ra.Add(r);
                    }
                    foreach (var ro in ra)
                    {
                        //ra.Add(ro);
                        UserAccess us = new UserAccess();
                        us.UserName       = model.UserName;
                        us.IsRead         = true; us.IsWrite = true;
                        us.ControllerName = ro.ControllerName;
                        us.ActionName     = ro.ActionName;
                        us.AssignDate     = DateTime.Now;
                        us.AssignUser     = User.Identity.Name;
                        us.ModuleListID   = ro.ModuleListID;
                        context.UserAccesses.Add(us);
                        int i = context.SaveChanges();
                    }
                }
                if (result.Succeeded)
                {
                    return("User Added Successfully.");
                }
                else
                {
                    string st = "";
                    foreach (var er in result.Errors)
                    {
                        st += er.ToString();
                    }
                    return(st);
                }
            }
            else
            {
                return("Please select any one Property for User");
            }
        }
Exemplo n.º 24
0
        public void SaveInstallments(string saledate, string saleprice, string salepriceword, int ddlInstallment, int ddlInterval, string eventName, string bspPercentage, string saleId, string flatId, string evName, string amount, string pplPrice)
        {
            REMSDBEntities context = new REMSDBEntities();
            DateTimeFormatInfo dtinfo = new DateTimeFormatInfo();
            dtinfo.DateSeparator = "/";
            dtinfo.ShortDatePattern = "dd/MM/yyyy";
            DateTime dt2 = DateTime.Now;
            if (saledate != "")
                dt2 = Convert.ToDateTime(saledate, dtinfo);

            var st = context.SaleFlats.Where(s => s.SaleID == Convert.ToInt32(saleId)).FirstOrDefault<SaleFlat>();
            st.SaleRate = Convert.ToDecimal(saleprice);
            st.SaleRateInWords = salepriceword;
            st.SaleDate = dt2;
            st.Status = "1";
            context.SaveChanges();

            StringBuilder l_StringBuilder = new StringBuilder();
            string PlanType = "";
            amount = amount.Replace("undefined,", "");
            amount = amount.TrimEnd(',');
            string[] amounts = amount.Split(',');
            evName = evName.Replace("undefined,", "");
            evName = evName.TrimEnd(',');
            string[] EvNames = evName.Split(',');
            string[] bspPer = bspPercentage.Split(',');
            var fsz = context.Flats.Where(s => s.FlatID == Convert.ToInt32(flatId)).ToList()[0].FlatSize;
            decimal.Parse(saleprice) * decimal.Parse(fsz.ToString());
            if (PlanType == "1")
            {
                DataTable tb = new DataTable();
                if (Session["table"] != null)
                {
                    tb = Session["table"] as DataTable;
                }
                if (tb.Rows.Count > 0)
                {
                    string[] EventIdd = EventName.Split(',');
                    int j = 0;
                    for (int a = 0; a < tb.Rows.Count; a++)
                    {
                        string InstallmentID = Convert.ToString(tb.Rows[a]["InstallmentID"]);
                        string InstallmentNo = Convert.ToString(tb.Rows[a]["InstallmentNo"]);
                        if (a > 0)
                        {
                            InstallmentNo = a.ToString();
                        }
                        string DueAmount = Convert.ToString(tb.Rows[a]["DueAmount"]);
                        string EventID = Convert.ToString(tb.Rows[a]["EventID"]);
                        string TotalAmount = Convert.ToString(tb.Rows[a]["TotalAmount"]);
                        if (DueAmount != "")
                        {
                            Hashtable ht = new Hashtable();
                            ht.Add("DueAmount", DueAmount);
                            ht.Add("DueAmtInWords", clsnew.rupees(Convert.ToInt64(DueAmount)));

                            ht.Add("TotalAmount", saleprice);
                            ht.Add("TotalAmtInWords", clsnew.rupees(Convert.ToInt64(saleprice)));
                            ht.Add("SaleID", Convert.ToInt32(Session["SaleID"].ToString()));
                            ht.Add("InstallmentNo", InstallmentNo);
                            ht.Add("EventName", InstallmentNo);

                            if (!String.IsNullOrEmpty(Convert.ToString(tb.Rows[a]["DueDate"])))
                            {
                                ht.Add("DueDate", obj.Text_IndianDateFormat(Convert.ToString(tb.Rows[a]["DueDate"])));
                            }
                            ht.Add("FlatID", Convert.ToInt32(Session["FlatID"].ToString()));
                            if (Session["TowerID"] != null)
                            {
                                ht.Add("TowerID", Convert.ToInt32(Session["TowerID"].ToString()));
                            }
                            if (InstallmentNo == "Booking Amount" || InstallmentNo == "Possession Amount")
                            {
                                ht.Add("Type", 0);
                            }
                            else
                            {
                                j++;
                                ht.Add("Type", 1);
                            }
                            ht.Add("Activity", "ADD");
                            if (obj.ExecuteProcedure("InsertInstallmentDetail", ht))
                            {
                            }
                        }
                    }
                }
            }
            else if (PlanType == "2")
            {
                DataTable tb = new DataTable();
                #region Construction Based Plan

                if (Session["table"] != null)
                {

                    tb = Session["table"] as DataTable;
                }
                if (tb.Rows.Count > 0)
                {
                    string[] EventIdd = EventName.Split(',');
                    int j = 0;
                    for (int a = 0; a < tb.Rows.Count; a++)
                    {
                        string InstallmentID = Convert.ToString(tb.Rows[a]["InstallmentID"]);
                        string InstallmentNo = Convert.ToString(tb.Rows[a]["InstallmentNo"]);
                        string DueAmount = Convert.ToString(tb.Rows[a]["DueAmount"]);
                        string EventID = Convert.ToString(tb.Rows[a]["EventID"]);
                        string TotalAmount = Convert.ToString(tb.Rows[a]["TotalAmount"]);
                        string DueDate = Convert.ToString(tb.Rows[a]["DueDate"]);
                        if (DueAmount != "")
                        {
                            Hashtable ht = new Hashtable();
                            ht.Add("DueAmount", amounts[a]);
                            ht.Add("DueAmtInWords", clsnew.rupees(Convert.ToDecimal(amounts[a])));

                            ht.Add("TotalAmount", amounts[a]);
                            ht.Add("TotalAmtInWords", clsnew.rupees(Convert.ToDecimal(amounts[a])));
                            ht.Add("SaleID", Convert.ToInt32(Session["SaleID"].ToString()));

                            if (DueDate != "")
                            {
                                ht.Add("DueDate", obj.Text_IndianDateFormat(Convert.ToString(tb.Rows[a]["DueDate"])));           /* Balkrishna  Add one Line By */
                            }

                            ht.Add("FlatID", Convert.ToInt32(Session["FlatID"].ToString()));
                            if (Session["TowerID"] != null)
                            {
                                ht.Add("TowerID", Convert.ToInt32(Session["TowerID"].ToString()));
                            }
                            if (InstallmentNo.Contains("Booking Amount") || InstallmentNo.Contains("Possession Amount"))
                            {
                                ht.Add("Type", 0);
                                ht.Add("InstallmentNo", InstallmentNo);
                                ht.Add("EventName", InstallmentNo);
                            }
                            else
                            {
                                if (!String.IsNullOrWhiteSpace(EventIdd[j]))
                                { ht.Add("EventID", Convert.ToInt32(EventIdd[j])); }
                                ht.Add("EventName", EvNames[j]);
                                ht.Add("InstallmentNo", EvNames[j]);
                                j++;
                                ht.Add("Type", 1);
                            }
                            ht.Add("Activity", "ADD");
                            ht.Add("Bsp", bspPer[a]);
                            if (obj.ExecuteProcedure("[InsertInstallmentDetail]", ht))
                            {
                            }
                        }
                    }
                }
                #endregion
            }
            else if (PlanType == "3")
            {
                #region Normal Mode
                DataTable dt = new DataTable();
                if (Session["table"] != null)
                    dt = (DataTable)Session["table"];
                //string EventName="";
                for (int a = 0; a < dt.Rows.Count; a++)
                {
                    string InstallmentID = Convert.ToString(a + 1);// Convert.ToString(dt.Rows[a]["InstallmentID"]);
                    EventName = Convert.ToString(dt.Rows[a]["Event"]);
                    string EventID = "0";
                    string InstallmentNo = Convert.ToString(dt.Rows[a]["Event"]);// Convert.ToString(dt.Rows[a]["InstallmentNo"]);
                    string DueDate = Convert.ToString(dt.Rows[a]["DueDate"]);
                    string DueAmount = Convert.ToString(dt.Rows[a]["Amount"]);
                    if (DueAmount != "")
                    {
                        Hashtable ht = new Hashtable();
                        if (DueDate != "")
                        {
                            ht.Add("DueDate", Convert.ToDateTime(DueDate, dtinfo));
                        }

                        ht.Add("DueAmount", amounts[a]);
                        ht.Add("DueAmtInWords", clsnew.rupees(Convert.ToInt64(amounts[a])));
                        // ht.Add("ServiceTaxAmount",ServiceTaxAmount.Text);
                        ht.Add("TotalAmount", amounts[a]);
                        ht.Add("TotalAmtInWords", clsnew.rupees(Convert.ToInt64(amounts[a])));
                        ht.Add("SaleID", Convert.ToInt32(Session["SaleID"].ToString()));
                        ht.Add("InstallmentNo", InstallmentNo);
                        ht.Add("FlatID", Convert.ToInt32(Session["FlatID"].ToString()));
                        ht.Add("Type", 0);
                        ht.Add("UserID", Convert.ToInt32("0"));
                        ht.Add("Activity", "Add");
                        ht.Add("EventName", EventName);
                        ht.Add("EventID", EventID);
                        ht.Add("FloorNo", 0);
                        ht.Add("TowerID", 0);
                        ht.Add("BID", 0);
                        ht.Add("BSP", bspPer[a]);
                        if (obj.ExecuteProcedure("InsertInstallmentDetailCLP", ht))
                        {
                        }
                    }
                }
                #endregion
            }
            else if (PlanType == "4" || PlanType == "5")
            {
                DataTable tb = new DataTable();
                #region Combo Plan

                if (Session["table"] != null)
                {
                    tb = Session["table"] as DataTable;
                }
                if (tb.Rows.Count > 0)
                {
                    string[] EventIdd = EventName.Split(',');
                    int j = 0;
                    for (int a = 0; a < tb.Rows.Count; a++)
                    {
                        string InstallmentID = Convert.ToString(tb.Rows[a]["InstallmentID"]);
                        string InstallmentNo = Convert.ToString(tb.Rows[a]["InstallmentNo"]);
                        string DueAmount = Convert.ToString(tb.Rows[a]["DueAmount"]);
                        string EventID = Convert.ToString(tb.Rows[a]["EventID"]);
                        string Eventorder = Convert.ToString(tb.Rows[a]["EventID"]);
                        string DueDate = "";
                        string TotalAmount = Convert.ToString(tb.Rows[a]["TotalAmount"]);
                        if (DueAmount != "")
                        {
                            Hashtable ht = new Hashtable();
                            if (InstallmentNo.Contains("Booking Amount"))
                            {
                                ht.Add("DueDate", obj.Text_IndianDateFormat(saledate));
                            }
                            if (DueDate != "")
                            {
                                ht.Add("DueDate", obj.Text_IndianDateFormat(DueDate));
                            }
                            ht.Add("DueAmount", amounts[a]);
                            ht.Add("DueAmtInWords", clsnew.rupees(Convert.ToDecimal(amounts[a])));
                            ht.Add("TotalAmount", amounts[a]);
                            ht.Add("TotalAmtInWords", clsnew.rupees(Convert.ToDecimal(amounts[a])));
                            ht.Add("SaleID", Convert.ToInt32(Session["SaleID"].ToString()));

                            ht.Add("FlatID", Convert.ToInt32(Session["FlatID"].ToString()));
                            if (Session["TowerID"] != null)
                            {
                                ht.Add("TowerID", Convert.ToInt32(Session["TowerID"].ToString()));
                            }
                            ht.Add("saleprice", saleprice);
                            ht.Add("InstallmentOrder", Eventorder);

                            if (InstallmentNo == "Booking Amount" || InstallmentNo == "Possession Amount")
                            {
                                ht.Add("Type", 0);
                                ht.Add("EventID", 0);
                                ht.Add("EventName", InstallmentNo);
                                ht.Add("InstallmentNo", InstallmentNo);
                            }
                            else
                            {
                                if (!String.IsNullOrWhiteSpace(EventIdd[j]))
                                { ht.Add("EventID", Convert.ToInt32(EventIdd[j])); }
                                ht.Add("EventName", EvNames[j]);
                                ht.Add("InstallmentNo", EvNames[j]);
                                j++;

                                ht.Add("Type", 1);
                            }
                            ht.Add("Activity", "ADD");
                            if (bspPer[a] != null && !String.IsNullOrWhiteSpace(bspPer[a]))
                            {
                                ht.Add("Bsp", bspPer[a]);
                            }
                            if (obj.ExecuteProcedure("InsertInstallmentDetailCombo", ht))
                            {
                            }
                        }
                    }
                }
                #endregion
            }
        }