//Get:User Classfication for update
 private void Get_UserClassificationForUpdate()
 {
     if (Request.QueryString["Id"] != null)
     {
         try
         {
             divoptions.Style.Add("display", "block");
             txtUserType.Enabled = false;
             int id = Convert.ToInt32(Request.QueryString["Id"].ToString());
             UserClassification Uc = repo.GetUserClassification_by_Id(id);
             if (Uc != null)
             {
                 txtUserType.Text = Uc.UserType;
                 ddlConfiguaration.SelectedValue        = ddlConfiguaration.Items.FindByValue(Uc.Configuration.Value == true ? "1" : "0").Value;
                 ddlDatabaseOperation.SelectedValue     = ddlDatabaseOperation.Items.FindByValue(Uc.DatabaseOperation.Value == true ? "1" : "0").Value;
                 ddlGateEntry.SelectedValue             = ddlGateEntry.Items.FindByValue(Uc.GateEntry.Value == true ? "1" : "0").Value;
                 ddlMasterFileDeletion.SelectedValue    = ddlMasterFileDeletion.Items.FindByValue(Uc.MasterFileUpdation.Value == true ? "1" : "0").Value;
                 ddlMasterRecordDeletion.SelectedValue  = ddlMasterRecordDeletion.Items.FindByValue(Uc.MasterRecordDeletion.Value == true ? "1" : "0").Value;
                 ddlPasswordPolicy.SelectedValue        = ddlPasswordPolicy.Items.FindByValue(Uc.PasswordPolicy.Value == true ? "1" : "0").Value;
                 ddlPasswordReset.SelectedValue         = ddlPasswordReset.Items.FindByValue(Uc.PasswordReset.Value == true ? "1" : "0").Value;
                 ddlPendingRecordDeletion.SelectedValue = ddlPendingRecordDeletion.Items.FindByValue(Uc.PendingRecordDeletion.Value == true ? "1" : "0").Value;
                 ddlRFIDIssue.SelectedValue             = ddlRFIDIssue.Items.FindByValue(Uc.RFIDIssue.Value == true ? "1" : "0").Value;
                 ddlTransactionDeletion.SelectedValue   = ddlTransactionDeletion.Items.FindByValue(Uc.TransactionDeletion.Value == true ? "1" : "0").Value;
                 ddlUserCreation.SelectedValue          = ddlUserCreation.Items.FindByValue(Uc.UserCreation.Value == true ? "1" : "0").Value;
                 ddlWeighment.SelectedValue             = ddlWeighment.Items.FindByValue(Uc.Weighment.Value == true ? "1" : "0").Value;
             }
         }
         catch (Exception ex)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('" + ex.Message.ToString() + "');", true);
         }
     }
 }
        internal UserClassification GetUserAuthorization(int id)
        {
            UserClassification um = (from a in db.UserMasters
                                     join b in db.UserClassifications on a.UserType equals b.Id
                                     where a.Id == id
                                     select b).FirstOrDefault();

            return(um);
        }
Beispiel #3
0
        //Add:New UserClassification
        public bool Add_UserClassification(UserClassification user)
        {
            bool status = false;

            if (user != null)
            {
                db.UserClassifications.InsertOnSubmit(user);
                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
Beispiel #4
0
        //Delete:UserClassification by Id
        public bool Delete_UserClassification(int id)
        {
            bool status           = false;
            UserClassification uc = db.UserClassifications.FirstOrDefault(x => x.Id == id && x.IsDeleted == false);

            if (uc != null)
            {
                uc.IsDeleted = true;
                db.SubmitChanges();
                status = true;
            }
            return(status);
        }
        protected void BtnLogin_Click(object sender, EventArgs e)
        {
            string               _UserName  = UserName.Value;
            string               _Password  = Password.Value;
            string               _WBID      = WBID.Value;
            string               _PlantID   = PlantID.Value;
            UserMaster           um         = umRepo.CheckUserCredentials(_UserName, _Password, _WBID, _PlantID);
            SiteParameterSetting setting    = db.SiteParameterSettings.FirstOrDefault();
            PlantMaster          _plantCode = db.PlantMasters.Where(x => x.PlantCode == _PlantID).FirstOrDefault();

            if (um != null && um.Id != 0)
            {
                Session["UserName"]    = _UserName;
                Session["Password"]    = _Password;
                Session["WBID"]        = _WBID;
                Session["UserId"]      = um.Id;
                Session["PlantID"]     = _PlantID;
                Session["CompanyCode"] = _plantCode.CompanyCode;
                Session["WBFORM"]      = "0";
                GLOBALVARIABLE();

                FormsAuthentication.RedirectFromLoginPage(um.Id.ToString(), true);
                UserClassification uc = umRepo.GetUserAuthorization(um.Id);
                New_Weighing_Unit(_WBID, _PlantID);

                Session["FIRSTWT_RCD"]  = "0";
                Session["SECONDWT_RCD"] = "0";
                if (uc != null)
                {
                    if (uc.GateEntry == true)
                    {
                        Response.Redirect("/GateEntryForm");
                    }
                    else if (uc.Weighment == false)
                    {
                        Session["WBFORM"] = "1";
                        Response.Redirect("/ManageMasters");
                    }
                    else
                    {
                        Response.Redirect("/Manual_Weighment");
                    }
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "myalert", "toastr.error('No User account found. Please try again.');", true);
            }
        }
 //Get:Update User Classification
 private void Update_UserClassification()
 {
     if (!string.IsNullOrEmpty(Request.QueryString["Id"]))
     {
         try
         {
             int Id = Convert.ToInt32(Request.QueryString["Id"].ToString());
             //UserClassification Uc = repo.GetUserClassification_by_Id(Id);
             UserClassification Uc = db.UserClassifications.FirstOrDefault(x => x.Id == Id && x.IsDeleted == false);
             if (Uc != null)
             {
                 UserClassification _data = repo.Get_ActiveUserClassificationList().Where(x => x.UserType == txtUserType.Text && x.IsDeleted == false && x.Id != Id).FirstOrDefault();
                 if (_data != null)
                 {
                     ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('Same usertype exist.please try again.');", true);
                 }
                 else
                 {
                     Uc.UserType              = txtUserType.Text;
                     Uc.Configuration         = ddlConfiguaration.SelectedItem.Value == "0" ? false : true;
                     Uc.DatabaseOperation     = ddlDatabaseOperation.SelectedItem.Value == "0" ? false : true;
                     Uc.GateEntry             = ddlGateEntry.SelectedItem.Value == "0" ? false : true;
                     Uc.MasterFileUpdation    = ddlMasterFileDeletion.SelectedItem.Value == "0" ? false : true;
                     Uc.MasterRecordDeletion  = ddlMasterRecordDeletion.SelectedItem.Value == "0" ? false : true;
                     Uc.PasswordPolicy        = ddlPasswordPolicy.SelectedItem.Value == "0" ? false : true;
                     Uc.PasswordReset         = ddlPasswordReset.SelectedItem.Value == "0" ? false : true;
                     Uc.PendingRecordDeletion = ddlPendingRecordDeletion.SelectedItem.Value == "0" ? false : true;
                     Uc.RFIDIssue             = ddlRFIDIssue.SelectedItem.Value == "0" ? false : true;
                     Uc.TransactionDeletion   = ddlTransactionDeletion.SelectedItem.Value == "0" ? false : true;
                     Uc.UserCreation          = ddlUserCreation.SelectedItem.Value == "0" ? false : true;
                     Uc.Weighment             = ddlWeighment.SelectedItem.Value == "0" ? false : true;
                     db.SubmitChanges();
                     ClientScript.RegisterStartupScript(this.GetType(), "myalert", "toastr.success('User Classification updated successfully.');", true);
                     HtmlMeta meta = new HtmlMeta
                     {
                         HttpEquiv = "Refresh",
                         Content   = "1;url=AddEdit.aspx?id=" + Id
                     };
                     this.Page.Controls.Add(meta);
                 }
             }
         }
         catch (Exception ex)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('" + ex.Message.ToString() + "');", true);
         }
     }
 }
 //:Add New UserType in UserClassification
 private void Add_UserClassification()
 {
     if (Request.QueryString["Id"] == null)
     {
         try
         {
             UserClassification Uc = repo.GetUserClassification_by_UserType(txtUserType.Text.Trim());
             if (Uc != null)
             {
                 ClientScript.RegisterStartupScript(this.GetType(), "myalert", "toastr.error('Same User type exist. Please try again later.');", true);
             }
             else
             {
                 Uc                       = new UserClassification();
                 Uc.UserType              = txtUserType.Text.Trim();
                 Uc.Configuration         = ddlConfiguaration.SelectedItem.Value == "0" ? false : true;
                 Uc.DatabaseOperation     = ddlDatabaseOperation.SelectedItem.Value == "0" ? false : true;
                 Uc.GateEntry             = ddlGateEntry.SelectedItem.Value == "0" ? false : true;
                 Uc.MasterFileUpdation    = ddlMasterFileDeletion.SelectedItem.Value == "0" ? false : true;
                 Uc.MasterRecordDeletion  = ddlMasterRecordDeletion.SelectedItem.Value == "0" ? false : true;
                 Uc.PasswordPolicy        = ddlPasswordPolicy.SelectedItem.Value == "0" ? false : true;
                 Uc.PasswordReset         = ddlPasswordReset.SelectedItem.Value == "0" ? false : true;
                 Uc.PendingRecordDeletion = ddlPendingRecordDeletion.SelectedItem.Value == "0" ? false : true;
                 Uc.RFIDIssue             = ddlRFIDIssue.SelectedItem.Value == "0" ? false : true;
                 Uc.TransactionDeletion   = ddlTransactionDeletion.SelectedItem.Value == "0" ? false : true;
                 Uc.UserCreation          = ddlUserCreation.SelectedItem.Value == "0" ? false : true;
                 Uc.Weighment             = ddlWeighment.SelectedItem.Value == "0" ? false : true;
                 Uc.IsDeleted             = false;
                 if (repo.Add_UserClassification(Uc))
                 {
                     ClientScript.RegisterStartupScript(this.GetType(), "myalert", "toastr.success('User Classification added successfully.');", true);
                     HtmlMeta meta = new HtmlMeta
                     {
                         HttpEquiv = "Refresh",
                         Content   = "1;url=AddEdit.aspx"
                     };
                     this.Page.Controls.Add(meta);
                 }
             }
         }
         catch (Exception ex)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.error('" + ex.Message.ToString() + "');", true);
         }
     }
 }
        //Get:Previous Record from user classification
        protected void Previous_Record_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["Id"].ToString());
            UserClassification next = null;

            try
            {
                next = repo.Get_ActiveUserClassificationList().Where(x => x.Id < id && x.IsDeleted == false).OrderByDescending(i => i.Id).FirstOrDefault();
            }
            catch
            {
            }
            if (next != null)
            {
                Response.Redirect("AddEdit.aspx?id=" + next.Id.ToString());
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('No more records founds.')", true);
            }
        }
Beispiel #9
0
        //Save Data To The Server
        public string SaveDataToServer(DataSet ds)
        {
            string result = string.Empty;

            using (DataClasses1DataContext db = new DataClasses1DataContext())
            {
                string    connection = ConfigurationManager.ConnectionStrings["AveryDBConnectionString"].ConnectionString;
                DataTable dt         = ds.Tables[0];
                int       _failed    = 0;
                int       _success   = 0;
                int       _update    = 0;
                foreach (DataRow dr in dt.Rows)
                {
                    string _UserType              = dr["User Type"].ToString();
                    bool   _MasterFileUpdation    = dr["Master File Updation"].ToString() == "Enable" ? true : false;
                    bool   _MasterRecordDeletion  = dr["Master Record Deletion"].ToString() == "Enable" ? true : false;
                    bool   _PendingRecordDeletion = dr["Pending Record Deletion"].ToString() == "Enable" ? true : false;
                    bool   _TransactionDeletion   = dr["Transaction Deletion"].ToString() == "Enable" ? true : false;
                    bool   _Configuration         = dr["Configuration"].ToString() == "Enable" ? true : false;
                    bool   _PasswordPolicy        = dr["Password Policy"].ToString() == "Enable" ? true : false;
                    bool   _PasswordReset         = dr["Password Reset"].ToString() == "Enable" ? true : false;
                    bool   _UserCreation          = dr["User Creation"].ToString() == "Enable" ? true : false;
                    bool   _GateEntry             = dr["Gate Entry"].ToString() == "Enable" ? true : false;
                    bool   _RFIDIssue             = dr["RFID Issue"].ToString() == "Enable" ? true : false;
                    bool   _Weighment             = dr["Weighment"].ToString() == "Enable" ? true : false;
                    bool   _DatabaseOperation     = dr["Database Operation"].ToString() == "Enable" ? true : false;
                    var    _Uc = db.UserClassifications.Where(x => x.UserType == _UserType && x.IsDeleted == false).FirstOrDefault();
                    if (_UserType.Length <= 25)
                    {
                        if (_Uc != null)
                        {
                            int id = db.UserClassifications.FirstOrDefault(x => x.UserType == _UserType && x.IsDeleted == false).Id;
                            UserClassification _User = db.UserClassifications.FirstOrDefault(x => x.UserType == _UserType && x.IsDeleted == false && x.Id != id);
                            if (_User != null)
                            {
                                _failed++;
                            }
                            else
                            {
                                _Uc.UserType              = _UserType;
                                _Uc.MasterFileUpdation    = _MasterFileUpdation;
                                _Uc.MasterRecordDeletion  = _MasterRecordDeletion;
                                _Uc.PendingRecordDeletion = _PendingRecordDeletion;
                                _Uc.TransactionDeletion   = _TransactionDeletion;
                                _Uc.Configuration         = _Configuration;
                                _Uc.PasswordPolicy        = _PasswordPolicy;
                                _Uc.PasswordReset         = _PasswordReset;
                                _Uc.UserCreation          = _UserCreation;
                                _Uc.GateEntry             = _GateEntry;
                                _Uc.RFIDIssue             = _RFIDIssue;
                                _Uc.Weighment             = _Weighment;
                                _Uc.DatabaseOperation     = _DatabaseOperation;
                                db.SubmitChanges();
                                _update++;
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(_UserType))
                            {
                                var data = db.UserClassifications.FirstOrDefault(x => x.UserType == _UserType && x.IsDeleted == false);
                                if (data != null)
                                {
                                    _failed++;
                                }
                                else
                                {
                                    UserClassification uc = new UserClassification();
                                    uc.UserType              = _UserType;
                                    uc.MasterFileUpdation    = _MasterFileUpdation;
                                    uc.MasterRecordDeletion  = _MasterRecordDeletion;
                                    uc.PendingRecordDeletion = _PendingRecordDeletion;
                                    uc.Configuration         = _Configuration;
                                    uc.PasswordPolicy        = _PasswordPolicy;
                                    uc.PasswordReset         = _PasswordReset;
                                    uc.RFIDIssue             = _RFIDIssue;
                                    uc.UserCreation          = _UserCreation;
                                    uc.TransactionDeletion   = _TransactionDeletion;
                                    uc.Weighment             = _Weighment;
                                    uc.DatabaseOperation     = _DatabaseOperation;
                                    uc.GateEntry             = _GateEntry;
                                    uc.IsDeleted             = false;
                                    db.UserClassifications.InsertOnSubmit(uc);
                                    db.SubmitChanges();
                                    _success++;
                                }
                            }
                            else
                            {
                                _failed++;
                            }
                        }
                    }
                }

                result = "New Added: " + _success + " Updated:  " + _update + "  Failed:  " + _failed + "";
            }
            return(result);
        }
Beispiel #10
0
        //Get:User Classification By Id
        public UserClassification GetUserClassification_by_Id(int id)
        {
            UserClassification uc = db.UserClassifications.FirstOrDefault(x => x.Id == id && x.IsDeleted == false);

            return(uc);
        }
Beispiel #11
0
        //Get:User Classification By UserType
        public UserClassification GetUserClassification_by_UserType(string type)
        {
            UserClassification uc = db.UserClassifications.FirstOrDefault(x => x.UserType == type && x.IsDeleted == false);

            return(uc);
        }