Example #1
0
        public void EditSetting(Setting s)
        {
            Setting set = context.Settings.FirstOrDefault(m => m.Key == s.Key);

            if (set != null)
            {
                set.Category = s.Category;
                set.Value    = s.Value;
                set.Option   = s.Option;
                set.Type     = s.Type;
                context.SaveChanges();
            }
            else
            {
                context.Settings.Add(s);

                context.SaveChanges();
            }
            //else
            //{
            //    set = new Setting();

            //    set.Category = s.Category;
            //    set.Key  = s.Key;
            //    set.Value = s.Value;
            //    set.Option = s.Option;
            //    set.Type = s.Type;

            //    context.Settings.AddObject(set);
            //}
        }
Example #2
0
        public static void AddRole(Role role)
        {
            CTSContext entities = new CTSContext();

            entities.Roles.Add(role);
            entities.SaveChanges();
        }
Example #3
0
 public void RemoveRole(string roleName, string userName)
 {
     BLL.CTSContext entities = new CTSContext();
     UserRole role = entities.UserRoles.Where(r => r.Role.Name == roleName && r.UserProfile.UserName == userName).SingleOrDefault();
     if (role != null)
     {
         entities.UserRoles.Remove(role);
         entities.SaveChanges();
     }
 }
Example #4
0
        public void RemoveRole(string roleName, string userName)
        {
            BLL.CTSContext entities = new CTSContext();
            UserRole       role     = entities.UserRoles.Where(r => r.Role.Name == roleName && r.UserProfile.UserName == userName).SingleOrDefault();

            if (role != null)
            {
                entities.UserRoles.Remove(role);
                entities.SaveChanges();
            }
        }
Example #5
0
 public void AddUserToRole(int roleId, string userName)
 {
     BLL.CTSContext entities = new CTSContext();
     UserProfile user = entities.UserProfiles.Where(p => p.UserName == userName).FirstOrDefault();
     if (user != null)
     {
         UserRole role = new UserRole();
         role.RoleID = roleId;
         role.UserProfileID = user.UserProfileID;
         entities.UserRoles.Add(role);
         entities.SaveChanges();
     }
 }
Example #6
0
        /// <summary>
        /// Updates the specified inserted.
        /// </summary>
        /// <param name="inserted">The inserted.</param>
        /// <param name="updated">The updated.</param>
        /// <param name="deleted">The deleted.</param>
        public void Update(List <BLL.DispatchDetail> inserted, List <BLL.DispatchDetail> updated,
                           List <BLL.DispatchDetail> deleted)
        {
            CTSContext db = new CTSContext();

            BLL.Dispatch orginal = db.Dispatches.Where(p => p.DispatchID == this.DispatchID).SingleOrDefault();
            if (orginal != null)
            {
                orginal.BidNumber       = this.BidNumber;
                orginal.DispatchDate    = this.DispatchDate;
                orginal.DriverName      = this.DriverName;
                orginal.FDPID           = this.FDPID;
                orginal.GIN             = this.GIN;
                orginal.PeriodYear      = this.PeriodYear;
                orginal.PeriodMonth     = this.PeriodMonth;
                orginal.PlateNo_Prime   = this.PlateNo_Prime;
                orginal.PlateNo_Trailer = this.PlateNo_Trailer;
                //orginal.ProgramID = this.ProgramID;
                orginal.RequisitionNo = this.RequisitionNo;
                orginal.Round         = this.Round;
                //orginal.StackNumber = this.StackNumber;
                //orginal.StoreID = this.StoreID;
                orginal.TransporterID = this.TransporterID;
                orginal.UserProfileID = this.UserProfileID;
                //orginal.WarehouseID = this.WarehouseID;
                orginal.WeighBridgeTicketNumber = this.WeighBridgeTicketNumber;
                orginal.Remark = this.Remark;
                orginal.DispatchedByStoreMan = this.DispatchedByStoreMan;
                //orginal.ProjectNumber = this.ProjectNumber;
                //orginal.SINumber = this.SINumber;



                foreach (BLL.DispatchDetail update in updated)
                {
                    BLL.DispatchDetail updatedCommodity = db.DispatchDetails.Where(p => p.DispatchDetailID == update.DispatchDetailID).SingleOrDefault();
                    if (updatedCommodity != null)
                    {
                        updatedCommodity.CommodityID = update.CommodityID;
                        updatedCommodity.Description = update.Description;
                        //updatedCommodity.DispatchedQuantityInUnit = update.DispatchedQuantityInUnit;
                        //updatedCommodity.DispatchedQuantityInMT = update.DispatchedQuantityInMT;
                        updatedCommodity.RequestedQunatityInUnit = update.RequestedQunatityInUnit;
                        updatedCommodity.RequestedQuantityInMT   = update.RequestedQuantityInMT;
                        updatedCommodity.UnitID = update.UnitID;
                    }
                }
                db.SaveChanges();
            }
        }
Example #7
0
        public void AddUserToRole(int roleId, string userName)
        {
            BLL.CTSContext entities = new CTSContext();
            UserProfile    user     = entities.UserProfiles.Where(p => p.UserName == userName).FirstOrDefault();

            if (user != null)
            {
                UserRole role = new UserRole();
                role.RoleID        = roleId;
                role.UserProfileID = user.UserProfileID;
                entities.UserRoles.Add(role);
                entities.SaveChanges();
            }
        }
Example #8
0
        public static void SendSMS(int fdpId, string text)
        {
            CTSContext db = new CTSContext();
            var contacts = (from contact in db.Contacts
                            where contact.FDPID == fdpId
                            select contact).ToList();
            foreach (Contact contact in contacts)
            {
              //              INSERT SMS (InOutInd, MobileNumber, Text, RequestDate, SendAfterDate, Status, StatusDate, Attempts, EventTag)
              //VALUES ('O', @MobileNumber, @SMSMessage, @Today, @SendAfterDate, 'pending', @Today, 0, 'SEND_SMS')
                SMS sms = new DRMFSS.BLL.SMS();
                sms.Attempts = 0;
                sms.EventTag = "SEND_SMS";
                sms.InOutInd = "O";
                sms.LastAttemptDate = null;
                sms.MobileNumber = contact.PhoneNo;
                sms.Text = text;
                sms.RequestDate = DateTime.Today;
                sms.SendAfterDate = DateTime.Today;
                sms.Status = "pending";
                sms.StatusDate = DateTime.Today;

                db.SMS.Add(sms);
                //try
                //{

                //}
                //catch (Exception e)
                //{

                //}

            }

            db.SaveChanges();
        }
Example #9
0
        public static void SendSMS(int fdpId, string text)
        {
            CTSContext db       = new CTSContext();
            var        contacts = (from contact in db.Contacts
                                   where contact.FDPID == fdpId
                                   select contact).ToList();

            foreach (Contact contact in contacts)
            {
                //              INSERT SMS (InOutInd, MobileNumber, Text, RequestDate, SendAfterDate, Status, StatusDate, Attempts, EventTag)
                //VALUES ('O', @MobileNumber, @SMSMessage, @Today, @SendAfterDate, 'pending', @Today, 0, 'SEND_SMS')
                SMS sms = new DRMFSS.BLL.SMS();
                sms.Attempts        = 0;
                sms.EventTag        = "SEND_SMS";
                sms.InOutInd        = "O";
                sms.LastAttemptDate = null;
                sms.MobileNumber    = contact.PhoneNo;
                sms.Text            = text;
                sms.RequestDate     = DateTime.Today;
                sms.SendAfterDate   = DateTime.Today;
                sms.Status          = "pending";
                sms.StatusDate      = DateTime.Today;

                db.SMS.Add(sms);
                //try
                //{

                //}
                //catch (Exception e)
                //{

                //}
            }

            db.SaveChanges();
        }
Example #10
0
 public void Save()
 {
     _context.SaveChanges();
 }
Example #11
0
        /// <summary>
        /// Updates the specified inserted.
        /// </summary>
        /// <param name="inserted">The inserted.</param>
        /// <param name="updated">The updated.</param>
        /// <param name="deleted">The deleted.</param>
        public void Update(List<BLL.ReceiveDetail> inserted, List<BLL.ReceiveDetail> updated,
            List<BLL.ReceiveDetail> deleted)
        {
            CTSContext db = new CTSContext();
            BLL.Receive orginal = db.Receives.SingleOrDefault(p => p.ReceiveID == this.ReceiveID);
            if (orginal != null)
            {

                // CreatedDate = DateTime.Now,
                orginal.ReceiptDate = this.ReceiptDate;
                // orginal.ReceiveID = this.ReceiveID;
                orginal.DriverName = this.DriverName;
                orginal.GRN = this.GRN;
                orginal.PlateNo_Prime = this.PlateNo_Prime;
                orginal.PlateNo_Trailer = this.PlateNo_Trailer;
                //orginal.StackNumber = this.StackNumber;
                orginal.TransporterID = this.TransporterID;
                orginal.HubID = this.HubID;
               // orginal.SINumber = this.SINumber;
                //orginal.CommodityTypeID = this.CommodityTypeID;

                orginal.WayBillNo = this.WayBillNo;
                orginal.ResponsibleDonorID = this.ResponsibleDonorID;
                orginal.SourceDonorID = this.SourceDonorID;

                //orginal.ReceivedByStoreMan = this.ReceivedByStoreMan;
                //orginal.CommoditySourceID = this.CommoditySourceID;
                orginal.WeightBeforeUnloading = this.WeightBeforeUnloading;
                orginal.WeightAfterUnloading = this.WeightAfterUnloading;
                orginal.Remark = this.Remark;
                orginal.VesselName = this.VesselName;
                orginal.PortName = this.PortName;
                orginal.WeightBridgeTicketNumber = this.WeightBridgeTicketNumber;

                foreach (BLL.ReceiveDetail insert in inserted)
                {
                    //TODO THIS should be in transaction
                    //orginal.ReceiveDetails.Add(insert);
                }

                foreach (BLL.ReceiveDetail delete in deleted)
                {
                    BLL.ReceiveDetail deletedCommodity = db.ReceiveDetails.SingleOrDefault(p => p.ReceiveDetailID == delete.ReceiveDetailID);
                    if (deletedCommodity != null)
                    {
                  //      db.ReceiveDetails.DeleteObject(deletedCommodity);
                    }
                }

                foreach (BLL.ReceiveDetail update in updated)
                {
                    BLL.ReceiveDetail updatedCommodity = db.ReceiveDetails.SingleOrDefault(p => p.ReceiveDetailID == update.ReceiveDetailID);
                    if (updatedCommodity != null)
                    {
                        //updatedCommodity.CommodityID = update.CommodityID;
                        updatedCommodity.Description = update.Description;
                        //updatedCommodity.ReceiveDetailID = update.ReceiveDetailID;
                        //updatedCommodity.SentQuantityInMT = update.SentQuantityInMT;
                        //updatedCommodity.ReceivedQuantityInMT = updatedCommodity.ReceivedQuantityInMT;
                        //updatedCommodity.SentQuantityInUnit = update.SentQuantityInUnit;
                        //updatedCommodity.UnitID = update.UnitID;
                    }
                }
                db.SaveChanges();
            }
        }
Example #12
0
        /// <summary>
        /// Updates the specified inserted.
        /// </summary>
        /// <param name="inserted">The inserted.</param>
        /// <param name="updated">The updated.</param>
        /// <param name="deleted">The deleted.</param>
        public void Update(List <BLL.ReceiveDetail> inserted, List <BLL.ReceiveDetail> updated,
                           List <BLL.ReceiveDetail> deleted)
        {
            CTSContext db = new CTSContext();

            BLL.Receive orginal = db.Receives.SingleOrDefault(p => p.ReceiveID == this.ReceiveID);
            if (orginal != null)
            {
                // CreatedDate = DateTime.Now,
                orginal.ReceiptDate = this.ReceiptDate;
                // orginal.ReceiveID = this.ReceiveID;
                orginal.DriverName      = this.DriverName;
                orginal.GRN             = this.GRN;
                orginal.PlateNo_Prime   = this.PlateNo_Prime;
                orginal.PlateNo_Trailer = this.PlateNo_Trailer;
                //orginal.StackNumber = this.StackNumber;
                orginal.TransporterID = this.TransporterID;
                orginal.HubID         = this.HubID;
                // orginal.SINumber = this.SINumber;
                //orginal.CommodityTypeID = this.CommodityTypeID;

                orginal.WayBillNo          = this.WayBillNo;
                orginal.ResponsibleDonorID = this.ResponsibleDonorID;
                orginal.SourceDonorID      = this.SourceDonorID;

                //orginal.ReceivedByStoreMan = this.ReceivedByStoreMan;
                //orginal.CommoditySourceID = this.CommoditySourceID;
                orginal.WeightBeforeUnloading = this.WeightBeforeUnloading;
                orginal.WeightAfterUnloading  = this.WeightAfterUnloading;
                orginal.Remark     = this.Remark;
                orginal.VesselName = this.VesselName;
                orginal.PortName   = this.PortName;
                orginal.WeightBridgeTicketNumber = this.WeightBridgeTicketNumber;


                foreach (BLL.ReceiveDetail insert in inserted)
                {
                    //TODO THIS should be in transaction
                    //orginal.ReceiveDetails.Add(insert);
                }

                foreach (BLL.ReceiveDetail delete in deleted)
                {
                    BLL.ReceiveDetail deletedCommodity = db.ReceiveDetails.SingleOrDefault(p => p.ReceiveDetailID == delete.ReceiveDetailID);
                    if (deletedCommodity != null)
                    {
                        //      db.ReceiveDetails.DeleteObject(deletedCommodity);
                    }
                }

                foreach (BLL.ReceiveDetail update in updated)
                {
                    BLL.ReceiveDetail updatedCommodity = db.ReceiveDetails.SingleOrDefault(p => p.ReceiveDetailID == update.ReceiveDetailID);
                    if (updatedCommodity != null)
                    {
                        //updatedCommodity.CommodityID = update.CommodityID;
                        updatedCommodity.Description = update.Description;
                        //updatedCommodity.ReceiveDetailID = update.ReceiveDetailID;
                        //updatedCommodity.SentQuantityInMT = update.SentQuantityInMT;
                        //updatedCommodity.ReceivedQuantityInMT = updatedCommodity.ReceivedQuantityInMT;
                        //updatedCommodity.SentQuantityInUnit = update.SentQuantityInUnit;
                        //updatedCommodity.UnitID = update.UnitID;
                    }
                }
                db.SaveChanges();
            }
        }
Example #13
0
 public static void AddRole(Role role)
 {
     CTSContext entities = new CTSContext();
     entities.Roles.Add(role);
     entities.SaveChanges();
 }
        public override bool ChangePassword(string username, string oldPassword, string newPassword)
        {
            if (ValidateUser(username, oldPassword))
            {
                var context = new CTSContext();
                UserProfile user = context.UserProfiles.Where(p => p.UserName == username).SingleOrDefault();
                if (user != null)
                {
                    user.Password = MD5Hashing.MD5Hash(newPassword);
                    context.SaveChanges();
                    return true;
                }
            }

            return false;
        }
Example #15
0
        /// <summary>
        /// Updates the specified inserted.
        /// </summary>
        /// <param name="inserted">The inserted.</param>
        /// <param name="updated">The updated.</param>
        /// <param name="deleted">The deleted.</param>
        public void Update(List<BLL.DispatchDetail> inserted, List<BLL.DispatchDetail> updated, 
            List<BLL.DispatchDetail> deleted)
        {
            CTSContext db = new CTSContext();
            BLL.Dispatch orginal = db.Dispatches.Where(p => p.DispatchID == this.DispatchID).SingleOrDefault();
                    if (orginal != null)
                    {
                        orginal.BidNumber = this.BidNumber;
                        orginal.DispatchDate = this.DispatchDate;
                        orginal.DriverName = this.DriverName;
                        orginal.FDPID = this.FDPID;
                        orginal.GIN = this.GIN;
                        orginal.PeriodYear = this.PeriodYear;
                        orginal.PeriodMonth = this.PeriodMonth;
                        orginal.PlateNo_Prime = this.PlateNo_Prime;
                        orginal.PlateNo_Trailer = this.PlateNo_Trailer;
                        //orginal.ProgramID = this.ProgramID;
                        orginal.RequisitionNo = this.RequisitionNo;
                        orginal.Round = this.Round;
                        //orginal.StackNumber = this.StackNumber;
                        //orginal.StoreID = this.StoreID;
                        orginal.TransporterID = this.TransporterID;
                        orginal.UserProfileID = this.UserProfileID;
                        //orginal.WarehouseID = this.WarehouseID;
                        orginal.WeighBridgeTicketNumber = this.WeighBridgeTicketNumber;
                        orginal.Remark = this.Remark;
                        orginal.DispatchedByStoreMan = this.DispatchedByStoreMan;
                        //orginal.ProjectNumber = this.ProjectNumber;
                        //orginal.SINumber = this.SINumber;

                        foreach (BLL.DispatchDetail update in updated)
                        {
                            BLL.DispatchDetail updatedCommodity = db.DispatchDetails.Where(p => p.DispatchDetailID == update.DispatchDetailID).SingleOrDefault();
                            if (updatedCommodity != null)
                            {
                                updatedCommodity.CommodityID = update.CommodityID;
                                updatedCommodity.Description = update.Description;
                                //updatedCommodity.DispatchedQuantityInUnit = update.DispatchedQuantityInUnit;
                                //updatedCommodity.DispatchedQuantityInMT = update.DispatchedQuantityInMT;
                                updatedCommodity.RequestedQunatityInUnit = update.RequestedQunatityInUnit;
                                updatedCommodity.RequestedQuantityInMT = update.RequestedQuantityInMT;
                                updatedCommodity.UnitID = update.UnitID;
                            }
                        }
                        db.SaveChanges();
                    }
        }