Exemplo n.º 1
0
    void Start()
    {
        //ulazak = 1;

        GameObject g           = GameObject.Find("Canvas");
        save       saveSkripta = g.GetComponent <save>();

        postavljenoVrijeme = System.Convert.ToInt16(save.vrime);
        Debug.Log("Vrijeme postavljeno na: " + postavljenoVrijeme);

        sound = GetComponent <AudioSource>();
        GetButtons();
        AddListeners();
        AddExiters();
        addGamePuzzles();
        shuffle(gamePuzzles);
        gameGuesses = gamePuzzles.Count / 2;

        Button btnPovratak = povratak.GetComponent <Button>();

        trigger = btnPovratak.gameObject.AddComponent <EventTrigger>();
        var pointerEnterPovratak = new EventTrigger.Entry();

        pointerEnterPovratak.eventID = EventTriggerType.PointerEnter;
        string povratakBtn = btnPovratak.gameObject.name;

        pointerEnterPovratak.callback.AddListener((e) => povratakFunkcija());
        trigger.triggers.Add(pointerEnterPovratak);
    }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == string.Empty)
            {
                errorProvider1.SetError(textBox1, "Required");
            }
            else if (textBox2.Text == string.Empty)
            {
                errorProvider1.SetError(textBox2, "Required");
            }
            else if (textBox3.Text == string.Empty)
            {
                errorProvider1.SetError(textBox3, "Required");
            }
            else if (textBox4.Text == string.Empty)
            {
                errorProvider1.SetError(textBox4, "Required");
            }
            else
            {
                s.insert("insert into Registration([Username],[Password],[Emailid],[Contactno]) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox4.Text + "','" + textBox3.Text + "')");
                MessageBox.Show("information saved successfully");
                s = null;

                textBox1.Text = string.Empty;
                textBox2.Text = string.Empty;
                textBox3.Text = string.Empty;
                textBox4.Text = string.Empty;
            }
        }
Exemplo n.º 3
0
 void Start()
 {
     sv = svGO.GetComponent<save>();
     tst = tstGO.GetComponent<teste>();
     adAP = adAPGO.GetComponent<addAP>();
     mp = mpGO.GetComponent<maxPoints>();
 }
Exemplo n.º 4
0
    protected void send(object sender, EventArgs e)
    {
        save s = new save();

        s.insert("insert into chat(chatfrom,chatto,message) values('" + Label1.Text + "','" + Session["empusername"] + "','" + tbmsg.Text + "')");
        tbmsg.Text = "";
    }
Exemplo n.º 5
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "Server1")
     {
         string ftplocation = "ftp://107.180.1.81";
         string file        = lblfilepath.Text; // Or on FreeBSD: "/usr/home/jared/test2.txt";
         string user        = "******";
         string password    = "******";
         UploadToFTP(ftplocation, file, user, password);
         save s = new save();
         s.insert("insert into Share(Friendid,Filename,servername) values('" + textBox1.Text + "','" + label3.Text + "','" + comboBox1.Text + "')");
         MessageBox.Show("Successfully Shared");
     }
     if (comboBox1.Text == "Server2")
     {
         string ftplocation = "ftp://107.180.1.81";
         string file        = lblfilepath.Text; // Or on FreeBSD: "/usr/home/jared/test2.txt";
         string user        = "******";
         string password    = "******";
         UploadToFTP(ftplocation, file, user, password);
         save s = new save();
         s.insert("insert into Share(Friendid,Filename,servername) values('" + textBox1.Text + "','" + label3.Text + "','" + comboBox1.Text + "')");
         MessageBox.Show("Successfully Shared");
     }
 }
        private void button1_Click(object sender, EventArgs e)
        {
            save s = new save();

            s.insert("update registration set status='" + comboBox1.Text + "' where id='" + textBox1.Text + "'");
            MessageBox.Show("Successfully Updated");
            getvalue();
        }
Exemplo n.º 7
0
    public void Loaddatas()
    {
        save save1 = new save();//实例化一个save类用来取本地的值

        save1.Loaddata();
        bloodline = save1.person.shengming;//取此时的persondata类里面的值
        Debug.Log(bloodline);
    }
Exemplo n.º 8
0
 void Start()
 {
     sv = svGO.GetComponent<save>();
     tst = tstGO.GetComponent<teste>();
     adAP = adAPGO.GetComponent<addAP>();
     mp = mpGO.GetComponent<maxPoints>();
     sn = snGO.GetComponent<SelecaoNiveis>();
     btns = btnsGO.GetComponent<buttons>();
 }
Exemplo n.º 9
0
                public static void save()
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    FileStream      stream    = new FileStream(path, FileMode.Create);
                    save            data      = new save();

                    formatter.Serialize(stream, data);
                    stream.Close();
                }
Exemplo n.º 10
0
 void Awake()
 {
     Instance = this;
     if (saveName != null)
     {
         loadWorld();
         saveOtherStuff.load();
         savePlayer.load();
     }
 }
Exemplo n.º 11
0
        public override string GenerateSave()
        {
            var s = new save()
            {
                seen = SeenHomeworks.Take(50).ToList(),
                info = Info
            };

            return(Program.Serialise(s));
        }
Exemplo n.º 12
0
        public override string GenerateSave()
        {
            var s = new save()
            {
                update    = AverageUpdateTimes,
                entries   = Entries,
                isolation = Isolation
            };

            return(Program.Serialise(s));
        }
Exemplo n.º 13
0
 void Start()
 {
     sv = svGO.GetComponent<save>();
     tst = tstGO.GetComponent<teste>();
     adAP = adAPGO.GetComponent<addAP>();
     mp = mpGO.GetComponent<maxPoints>();
     sn = snGO.GetComponent<SelecaoNiveis>();
     btns = btnsGO.GetComponent<buttons>();
     btl = btlGO.GetComponent<Battle>();
     ce = ceGO.GetComponent<CreateEnemys>();
 }
Exemplo n.º 14
0
 void Awake()
 {
     if(saver==null)
     {
         DontDestroyOnLoad(gameObject);
         saver = this;
     }
     else if(saver!=null)
     {
         Destroy(gameObject);
     }
 }
Exemplo n.º 15
0
        private void button1_Click(object sender, EventArgs e)
        {
            int c = 1;

            if (textBox1.Text == string.Empty)
            {
                errorProvider1.SetError(textBox1, "Required");
                c = 0;
            }
            if (textBox2.Text == string.Empty)
            {
                c = 0;
                errorProvider1.SetError(textBox2, "Required");
            }
            else if (textBox3.Text == string.Empty)
            {
                errorProvider1.SetError(textBox3, "Required");
            }
            if (textBox4.Text == string.Empty)
            {
                c = 0;
                errorProvider1.SetError(textBox4, "Required");
            }
            if (textBox3.Text.Length < 10)
            {
                c = 0;
                errorProvider1.SetError(textBox3, "Required");
            }
            if (c == 1)
            {
                string         query = "select * from [Registration] where [Username]='" + textBox1.Text + "'";
                SqlDataAdapter sda   = new SqlDataAdapter(query, con);
                DataTable      dt    = new DataTable();
                sda.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    MessageBox.Show("already exixst");
                }
                if (dt.Rows.Count == 0)
                {
                    s.insert("insert into Registration([Username],[Password],[Emailid],[Contactno]) values('" + textBox1.Text + "','" + textBox2.Text + "','" + textBox4.Text + "','" + textBox3.Text + "')");
                    MessageBox.Show("information saved successfully");
                    s = null;

                    textBox1.Text = string.Empty;
                    textBox2.Text = string.Empty;
                    textBox3.Text = string.Empty;
                    textBox4.Text = string.Empty;
                }
            }
        }
Exemplo n.º 16
0
 void Start()
 {
     sv = svGO.GetComponent<save>();
     tst = tstGO.GetComponent<teste>();
     adAP = adAPGO.GetComponent<addAP>();
     mp = mpGO.GetComponent<maxPoints>();
     sn = snGO.GetComponent<SelecaoNiveis>();
     btns = btnsGO.GetComponent<buttons>();
     btl = btlGO.GetComponent<Battle>();
     ce = ceGO.GetComponent<CreateEnemys>();
     lu = luGO.GetComponent<LevelUp>();
     ask = askGO.GetComponent<ActivateSkills>();
     us = usGO.GetComponent<UseSkills>();
 }
Exemplo n.º 17
0
 public static void load()
 {
     if (File.Exists(path))
     {
         BinaryFormatter formatter = new BinaryFormatter();
         FileStream      stream    = new FileStream(path, FileMode.Open);
         save            ata       = formatter.Deserialize(stream) as save;
         stream.Close();
         serverdata.set(ata.server);
     }
     else
     {
         Console.WriteLine("You f****d up");
     }
 }
Exemplo n.º 18
0
        private void button1_Click(object sender, EventArgs e)
        {
            string ftplocation = "ftp://107.180.1.81";
            string file        = lblfilepath.Text; // Or on FreeBSD: "/usr/home/jared/test2.txt";
            string user        = "******";
            string password    = "******";

            UploadToFTP(ftplocation, file, user, password);
            save s = new save();

            s.insert("insert into FileDetails(Uploadedby,Filename,ReadPermission,keywords,sharedto) values('" + uploadedby + "','" + label3.Text + "','" + comboBox1.Text + "','" + textBox2.Text + "','" + textBox1.Text + "')");
            cafemanagement.Login l = new cafemanagement.Login();
            l.SendEmail(textBox1.Text, "You Received a file", "lbsim.in/" + label3.Text);
            MessageBox.Show("Successfully Shared");
        }
Exemplo n.º 19
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username  = tb_Username.Text.Trim();
            string spassword = tb_Password.Text.Trim();
            string skey      = tb_Key.Text.Trim();

            key = Encoding.Unicode.GetBytes(skey);
            byte[] pass = Encoding.Unicode.GetBytes(spassword);

            if (key.Length < 32)
            {
                MessageBox.Show("Login failed");
                return;
            }

            pass = Encrypt(pass);
            var hash = HashAlgorithm.Create("SHA256");

            byte[] hashpass = hash.ComputeHash(pass);

            save d = new save();

            try
            {
                FileStream      fs        = new FileStream("../../Login.dat", FileMode.Open);
                BinaryFormatter formatter = new BinaryFormatter();
                d = (save)formatter.Deserialize(fs);
                fs.Close();
            }
            catch (Exception k)
            {
                Console.WriteLine("Failed to deserialize. Reason: " + k.Message);
                throw;
            }

            if (d.username != username || !d.password.SequenceEqual(hashpass))
            {
                MessageBox.Show("Login failed");
                return;
            }

            this.Hide();
            Form f = new Server();

            f.Closed += (s, args) => this.Close();
            f.Show();
        }
Exemplo n.º 20
0
 public bool AddSave(save s)
 {
     try
     {
         using (QLBH_PHONE_ENTITY data = new QLBH_PHONE_ENTITY())
         {
             data.saves.Add(s);
             data.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
         return(false);
     }
 }
Exemplo n.º 21
0
 void Start()
 {
     Game_Over        = false;
     Next_Game        = false;
     Restart_Game     = false;
     GameOver.text    = "";
     NextGame.text    = "";
     RestartGame.text = "";
     //Hit = 0;
     //Coin = 0;
     //Health = 5;
     sf   = GameObject.FindWithTag("savefunction");
     comp = sf.GetComponent <save>();
     Coin = comp.Coin;
     Hit  = comp.Hit;
     Text = GetComponent <Text>();
     // UpdateScore();
     // anim = gameObject.GetComponent<Animator>();
     // Debug.Log("start");
 }
Exemplo n.º 22
0
 public bool UpdateSave(save s)
 {
     try
     {
         using (QLBH_PHONE_ENTITY data = new QLBH_PHONE_ENTITY())
         {
             //Test
             var getItem = data.saves.Single(p => p.id == s.id);
             //data.Entry(s).State = EntityState.Modified;
             getItem = s;
             data.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
         return(false);
     }
 }
Exemplo n.º 23
0
 public void Salvar()
 {
     if (string.IsNullOrWhiteSpace(titulo.GetComponent <InputField>().text))
     {
         titulo.GetComponent <InputField>().placeholder.GetComponent <Text>().text = "Digite um titulo antes!";
     }
     else
     {
         var save = new save
         {
             titulo           = titulo.text,
             fundoSelecionado = Climax.fundoSelecionado,
             itens            = Climax.itens.Select(x => new data
             {
                 posicao          = x.transform.position,
                 rotacao          = x.transform.localRotation,
                 tamanho          = x.transform.localScale,
                 indexSelecionado = int.Parse(x.name.Split('|')[0]),
                 indexImage       = int.Parse(x.name.Split('|')[1])
             }).ToList()
         };
         if (Climax.IdSalvo == 0)
         {
             using (dbconn = new SqliteConnection(conn))
             {
                 dbconn.Open(); //Open connection to the database.
                 dbcmd             = dbconn.CreateCommand();
                 sqlQuery          = $"INSERT INTO Saves (Name, Json) VALUES ('{titulo.GetComponent<InputField>().text}','{JsonUtility.ToJson(save)}')";
                 dbcmd.CommandText = sqlQuery;
                 dbcmd.ExecuteScalar();
                 dbconn.Close();
             }
             using (dbconn = new SqliteConnection(conn))
             {
                 dbconn.Open();
                 IDbCommand dbcmd    = dbconn.CreateCommand();
                 string     sqlQuery = "SELECT MAX(Id) FROM Saves";
                 dbcmd.CommandText = sqlQuery;
                 IDataReader reader = dbcmd.ExecuteReader();
                 while (reader.Read())
                 {
                     Climax.IdSalvo = reader.GetInt32(0);
                 }
                 reader.Close();
                 reader = null;
                 dbcmd.Dispose();
                 dbcmd = null;
                 dbconn.Close();
             }
         }
         else
         {
             using (dbconn = new SqliteConnection(conn))
             {
                 dbconn.Open(); //Open connection to the database.
                 dbcmd             = dbconn.CreateCommand();
                 sqlQuery          = $"UPDATE Saves SET Json = '{JsonUtility.ToJson(save)}' WHERE Id =" + Climax.IdSalvo;
                 dbcmd.CommandText = sqlQuery;
                 dbcmd.ExecuteScalar();
                 dbconn.Close();
             }
         }
         showAlert(true);
     }
 }
Exemplo n.º 24
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            XHD.BLL.ssn_role     role  = new XHD.BLL.ssn_role();
            XHD.BLL.ssn_art_menu menu  = new XHD.BLL.ssn_art_menu();
            XHD.Model.ssn_role   model = new XHD.Model.ssn_role();
            XHD.BLL.ssn_visit    visit = new XHD.BLL.ssn_visit();
            XHD.BLL.ssn_art      art   = new XHD.BLL.ssn_art();
            var    cookie     = context.Request.Cookies[FormsAuthentication.FormsCookieName];
            var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
            string CoockiesID = ticket.UserData;

            XHD.BLL.hr_employee emp = new XHD.BLL.hr_employee();
            int     emp_id          = int.Parse(CoockiesID);
            DataSet dsemp           = emp.GetList("id=" + emp_id);
            string  empname         = string.Empty;
            string  uid             = string.Empty;
            string  factory_Id      = string.Empty;

            if (dsemp != null && dsemp.Tables[0].Rows.Count > 0)
            {
                empname    = dsemp.Tables[0].Rows[0]["name"].ToString();
                uid        = dsemp.Tables[0].Rows[0]["uid"].ToString();
                factory_Id = dsemp.Tables[0].Rows[0]["Factory_Id"].ToString();
            }

            //角色保存
            if (request["Action"] == "SysSave")
            {
                model.RoleName    = PageValidate.InputText(request["T_role"], 250);
                model.RoleSort    = int.Parse(request["T_RoleOrder"]);
                model.RoleDscript = PageValidate.InputText(request["T_Descript"], 255);
                model.Factory_Id  = factory_Id;

                string id = PageValidate.InputText(request["id"], 50);

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = role.GetList("RoleID=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];
                    model.RoleID     = int.Parse(id);
                    model.UpdateDate = DateTime.Now;
                    model.UpdateID   = emp_id;
                    role.Update(model);
                }
                else
                {
                    model.CreateID   = emp_id;
                    model.CreateDate = DateTime.Now;
                    int rid = role.Add(model);
                }
            }

            //验证是否唯一
            else if (request["Action"] == "Exist")
            {
                DataSet ds1 = role.GetList(" RoleName='" + XHD.Common.PageValidate.InputText(request["T_role"], 250) + "'" + " and factory_Id='" + factory_Id + "'");
                context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true");
            }

            //获取角色表格json
            else if (request["Action"] == "grid")
            {
                DataSet ds = role.GetList(0, "factory_Id='" + factory_Id + "'", " RoleSort");

                string dt = XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);

                context.Response.Write(dt);
            }

            //获取角色信息
            else if (request["Action"] == "form")
            {
                DataSet ds = role.GetList(" RoleID=" + int.Parse(request["id"]));

                string dt = XHD.Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //删除角色
            else if (request["Action"] == "del")
            {
                string rid   = request["id"];
                bool   isdel = role.Delete(int.Parse(rid));
                if (isdel)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }

                //角色下员工删除
                XHD.BLL.ssn_role_emp rm = new XHD.BLL.ssn_role_emp();
                rm.Delete("RoleID=" + int.Parse(rid));

                //角色下数据权限删除
                XHD.BLL.ssn_visit data_auth = new XHD.BLL.ssn_visit();
                data_auth.DeleteByRole(int.Parse(rid));

                //角色下功能权限删除
                XHD.BLL.ssn_authority auth = new XHD.BLL.ssn_authority();
                auth.DeleteWhere("Role_id=" + int.Parse(rid));
            }

            #region 权限设置
            //auth
            else if (request["Action"] == "treegrid")
            {
                string appidstr = request["appid"];
                int    appid    = int.Parse(appidstr);

                //获取单位
                string ftyid = PageValidate.InputText(request["factory_id"], 60);
                //设置查询条件
                string wheretext  = "App_id=" + appid; //限制menu
                string wheretext2 = "";                //限制button

                DataTable dt = menu.GetList(wheretext).Tables[0];
                dt.Columns.Add(new DataColumn("Sysroler", typeof(string)));

                XHD.BLL.ssn_button btn = new XHD.BLL.ssn_button();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataSet ds    = btn.GetList(0, "Menu_id=" + dt.Rows[i]["Menu_id"].ToString() + wheretext2, "Btn_order");
                    string  roler = "";
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                        {
                            roler += ds.Tables[0].Rows[j]["Btn_id"].ToString() + "|" + ds.Tables[0].Rows[j]["Btn_name"].ToString();
                            roler += ",";
                        }
                    }
                    dt.Rows[i][dt.Columns.Count - 1] = roler;
                }
                string dt1 = "{Rows:[" + GetTasksString(0, dt) + "]}";
                context.Response.Write(dt1);
                context.Response.End();
            }
            //get auth
            else if (request["Action"] == "getauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                XHD.Model.ssn_authority modelauth = new XHD.Model.ssn_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = sa.app;
                modelauth.Menu_ids   = sa.menu;
                modelauth.Button_ids = sa.btn;

                XHD.BLL.ssn_authority sysau = new XHD.BLL.ssn_authority();

                string  roledata = "0|0";
                DataSet ds       = sysau.GetList("Role_id=" + modelauth.Role_id + " and App_ids='" + modelauth.App_ids + "'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    roledata = dr["Menu_ids"] + "|" + dr["Button_ids"];
                }
                context.Response.Write(roledata);
            }
            // save auth
            else if (request["Action"] == "saveauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                XHD.Model.ssn_authority modelauth = new XHD.Model.ssn_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = PageValidate.InputText(sa.app, 50);
                modelauth.Menu_ids   = PageValidate.InputText(sa.menu, int.MaxValue);
                modelauth.Button_ids = PageValidate.InputText(sa.btn, int.MaxValue);
                modelauth.Factory_Id = factory_Id;

                XHD.BLL.ssn_authority sysau = new XHD.BLL.ssn_authority();
                //List<string> relstbtn = new List<string>();

                if (!string.IsNullOrEmpty(postdata))
                {
                    //给角色分配权限
                    sysau.DeleteWhere("Role_id=" + modelauth.Role_id + " and App_ids='" + modelauth.App_ids + "'");
                    if (modelauth.Menu_ids != "" || modelauth.Button_ids != ",,")
                    {
                        sysau.Add(modelauth);
                    }
                    context.Response.Write("{sucess:sucess}");
                }
            }
            #endregion

            #region 查看权限设置
            //菜单显示
            else if (request["Action"] == "menuList")
            {
                string appid   = request["appid"];
                string authtxt = PageValidate.InputText(request["auth"], 50);

                if (!string.IsNullOrEmpty(appid))
                {
                    string serchtxt = " App_id=" + int.Parse(appid);
                    //-context.Response.Write(authtxt);
                    DataSet       ds  = menu.GetList(0, serchtxt, " Menu_order");
                    StringBuilder str = new StringBuilder();
                    str.Append("[");
                    str.Append(GetTreeString(0, ds.Tables[0], authtxt));
                    str.Replace(",", "", str.Length - 1, 1);
                    str.Append("]");
                    context.Response.Write(str);
                }
            }

            //显示菜单下的文章
            else if (request["Action"] == "viewgrid")
            {
                //通过菜单id获取旗下的文章
                string menuid = request["menuid"];

                if (!string.IsNullOrEmpty(menuid))
                {
                    string  serchtxt = " Factory_Id='" + factory_Id + "' and Art_Menu_Id=" + int.Parse(menuid) + " and is_del=0 ";
                    DataSet ds       = art.GetList(serchtxt);

                    string dt = XHD.Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);
                    context.Response.Write(dt);
                }
            }

            //保存查看权限
            else if (request["Action"] == "saveview")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                view sa = json.Deserialize <view>(postdata);
                XHD.Model.ssn_visit modelview = new XHD.Model.ssn_visit();
                modelview.Role_id     = int.Parse(sa.role_id);
                modelview.App_ids     = PageValidate.InputText(sa.app, 50);
                modelview.Menu_ids    = PageValidate.InputText(sa.menu, int.MaxValue);
                modelview.Art_id      = PageValidate.InputText(sa.art, int.MaxValue);
                modelview.Factory_Id  = factory_Id;
                modelview.Create_id   = emp_id;
                modelview.Create_date = DateTime.Now;

                if (!string.IsNullOrEmpty(postdata))
                {
                    //给角色分配权限
                    visit.DeleteWhere("Role_id=" + modelview.Role_id + " and Menu_ids='" + modelview.Menu_ids + "'");
                    if (modelview.Art_id != "")
                    {
                        visit.Add(modelview);
                    }
                    context.Response.Write("{sucess:sucess}");
                }
            }
            //获取当前角色的权限
            else if (request["Action"] == "getview")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                view sa = json.Deserialize <view>(postdata);
                XHD.Model.ssn_visit modelview = new XHD.Model.ssn_visit();
                modelview.Role_id  = int.Parse(sa.role_id);
                modelview.App_ids  = sa.app;
                modelview.Menu_ids = sa.menu;
                modelview.Art_id   = sa.art;

                string  roledata = "";
                DataSet ds       = visit.GetList("Role_id=" + modelview.Role_id + " and Menu_ids='" + modelview.Menu_ids + "'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    roledata = dr["Art_id"].ToString();
                }
                context.Response.Write(roledata);
            }

            #endregion
        }
Exemplo n.º 25
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_role    role  = new BLL.Sys_role();
            Model.Sys_role  model = new Model.Sys_role();
            BLL.hr_employee emp   = new BLL.hr_employee();

            //save
            if (request["Action"] == "SysSave")
            {
                model.RoleName    = PageValidate.InputText(request["T_role"], 250);
                model.RoleSort    = PageValidate.InputText(request["T_RoleOrder"], 10);
                model.RoleDscript = PageValidate.InputText(request["T_Descript"], 255);

                string id = request["id"];

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = role.GetList("RoleID=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];
                    model.RoleID     = int.Parse(id);
                    model.CreateID   = int.Parse(dr["CreateID"].ToString());
                    model.CreateDate = DateTime.Parse(dr["CreateDate"].ToString());
                    model.UpdateDate = DateTime.Now;
                    model.UpdateID   = int.Parse(request.Cookies["UserID"].Value);
                    role.Update(model);
                }
                else
                {
                    model.CreateID   = int.Parse(request.Cookies["UserID"].Value);
                    model.CreateDate = DateTime.Now;
                    role.Add(model);
                }
            }

            //validate
            if (request["Action"] == "Exist")
            {
                DataSet ds1 = role.GetList(" RoleName='" + Common.PageValidate.InputText(request["T_role"], 250) + "'");
                context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true");
            }

            //表格json
            if (request["Action"] == "grid")
            {
                DataSet ds = role.GetList(0, "", " RoleSort");

                string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);

                context.Response.Write(dt);
            }

            //Form JSON
            if (request["Action"] == "form")
            {
                DataSet ds = role.GetList(" RoleID=" + int.Parse(request["id"]));

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "del")
            {
                bool isdel = role.Delete(int.Parse(request["id"]));
                if (isdel)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }
            }
            //auth
            if (request["Action"] == "treegrid")
            {
                int          appid = int.Parse(request["appid"]);
                BLL.Sys_Menu menu  = new BLL.Sys_Menu();

                //string dt1 =
                DataTable dt = menu.GetList("App_id=" + appid).Tables[0];
                dt.Columns.Add(new DataColumn("Sysroler", typeof(string)));

                BLL.Sys_Button btn = new BLL.Sys_Button();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataSet ds    = btn.GetList(0, "Menu_id=" + dt.Rows[i]["Menu_id"].ToString(), " convert(int,[Btn_order])");
                    string  roler = "";
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                        {
                            roler += ds.Tables[0].Rows[j]["Btn_id"].ToString() + "|" + ds.Tables[0].Rows[j]["Btn_name"].ToString();
                            roler += ",";
                        }
                    }
                    dt.Rows[i][dt.Columns.Count - 1] = roler;
                }
                string dt1 = "{Rows:[" + GetTasksString(0, dt) + "]}";
                context.Response.Write(dt1);
                context.Response.End();
            }
            //get auth
            if (request["Action"] == "getauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                Model.Sys_authority modelauth = new Model.Sys_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = sa.app;
                modelauth.Menu_ids   = sa.menu;
                modelauth.Button_ids = sa.btn;

                BLL.Sys_authority sysau    = new BLL.Sys_authority();
                DataSet           ds       = sysau.GetList("Role_id=" + modelauth.Role_id + " and App_ids='a" + modelauth.App_ids + ",'");
                DataRow           dr       = ds.Tables[0].Rows[0];
                string            roledata = dr["Menu_ids"] + "|" + dr["Button_ids"];
                context.Response.Write(roledata);
            }
            // save auth
            if (request["Action"] == "saveauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                Model.Sys_authority modelauth = new Model.Sys_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = sa.app;
                modelauth.Menu_ids   = sa.menu;
                modelauth.Button_ids = sa.btn;

                BLL.Sys_authority sysau = new BLL.Sys_authority();

                if (!string.IsNullOrEmpty(postdata))
                {
                    sysau.DeleteWhere("Role_id=" + modelauth.Role_id + " and App_ids='" + modelauth.App_ids + "'");
                    sysau.Add(modelauth);

                    context.Response.Write("{sucess:sucess}");

                    //日志
                    BLL.Sys_log   log      = new BLL.Sys_log();
                    Model.Sys_log modellog = new Model.Sys_log();

                    DataSet dsemp = emp.GetList("id=" + request.Cookies["UserID"].Value);
                    modellog.EventDate = DateTime.Now;
                    modellog.UserID    = int.Parse(request.Cookies["UserID"].Value);
                    modellog.UserName  = dsemp.Tables[0].Rows[0]["name"].ToString();
                    modellog.IPStreet  = request.UserHostAddress;

                    modellog.EventType = "权限修改";
                    modellog.EventID   = modelauth.Role_id.ToString();
                    log.Add(modellog);
                }
            }
        }
Exemplo n.º 26
0
 var(save, result) = action();
Exemplo n.º 27
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            HttpRequest request = context.Request;

            BLL.Sys_role   role  = new BLL.Sys_role();
            Model.Sys_role model = new Model.Sys_role();

            var    cookie     = context.Request.Cookies[FormsAuthentication.FormsCookieName];
            var    ticket     = FormsAuthentication.Decrypt(cookie.Value);
            string CoockiesID = ticket.UserData;

            BLL.hr_employee emp     = new BLL.hr_employee();
            int             emp_id  = int.Parse(CoockiesID);
            DataSet         dsemp   = emp.GetList("id=" + emp_id);
            string          empname = dsemp.Tables[0].Rows[0]["name"].ToString();
            string          uid     = dsemp.Tables[0].Rows[0]["uid"].ToString();

            //save
            if (request["Action"] == "SysSave")
            {
                model.RoleName    = PageValidate.InputText(request["T_role"], 250);
                model.RoleSort    = int.Parse(request["T_RoleOrder"]);
                model.RoleDscript = PageValidate.InputText(request["T_Descript"], 255);

                string id = PageValidate.InputText(request["id"], 50);

                if (!string.IsNullOrEmpty(id) && id != "null")
                {
                    DataSet ds = role.GetList("RoleID=" + int.Parse(id));
                    DataRow dr = ds.Tables[0].Rows[0];
                    model.RoleID     = int.Parse(id);
                    model.UpdateDate = DateTime.Now;
                    model.UpdateID   = emp_id;
                    role.Update(model);
                }
                else
                {
                    model.CreateID   = emp_id;
                    model.CreateDate = DateTime.Now;
                    int rid = role.Add(model);

                    BLL.Sys_data_authority   auth     = new BLL.Sys_data_authority();
                    Model.Sys_data_authority modelsda = new Model.Sys_data_authority();

                    //默认数据权限
                    modelsda.Role_id  = rid;
                    modelsda.Sys_view = 1;
                    modelsda.Sys_add  = 1;
                    modelsda.Sys_edit = 1;
                    modelsda.Sys_del  = 1;

                    modelsda.option_id  = 1;
                    modelsda.Sys_option = "客户管理";
                    auth.Add(modelsda);

                    modelsda.option_id  = 2;
                    modelsda.Sys_option = "跟进管理";
                    auth.Add(modelsda);

                    modelsda.option_id  = 3;
                    modelsda.Sys_option = "订单管理";
                    auth.Add(modelsda);

                    modelsda.option_id  = 4;
                    modelsda.Sys_option = "合同管理";
                    auth.Add(modelsda);
                }
            }

            //validate
            if (request["Action"] == "Exist")
            {
                DataSet ds1 = role.GetList(" RoleName='" + Common.PageValidate.InputText(request["T_role"], 250) + "'");
                context.Response.Write(ds1.Tables[0].Rows.Count > 0 ? "false" : "true");
            }

            //表格json
            if (request["Action"] == "grid")
            {
                DataSet ds = role.GetList(0, "", " RoleSort");

                string dt = Common.GetGridJSON.DataTableToJSON(ds.Tables[0]);

                context.Response.Write(dt);
            }

            //Form JSON
            if (request["Action"] == "form")
            {
                DataSet ds = role.GetList(" RoleID=" + int.Parse(request["id"]));

                string dt = Common.DataToJson.DataToJSON(ds);

                context.Response.Write(dt);
            }
            //del
            if (request["Action"] == "del")
            {
                string rid   = request["id"];
                bool   isdel = role.Delete(int.Parse(rid));
                if (isdel)
                {
                    context.Response.Write("true");
                }
                else
                {
                    context.Response.Write("false");
                }

                //角色下员工删除
                BLL.Sys_role_emp rm = new BLL.Sys_role_emp();
                rm.Delete("RoleID=" + int.Parse(rid));

                //角色下数据权限删除
                BLL.Sys_data_authority auth = new BLL.Sys_data_authority();
                auth.Delete("Role_id=" + int.Parse(rid));
            }
            //auth
            if (request["Action"] == "treegrid")
            {
                int          appid = int.Parse(request["appid"]);
                BLL.Sys_Menu menu  = new BLL.Sys_Menu();

                //string dt1 =
                DataTable dt = menu.GetList("App_id=" + appid).Tables[0];
                dt.Columns.Add(new DataColumn("Sysroler", typeof(string)));

                BLL.Sys_Button btn = new BLL.Sys_Button();
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    //DataSet ds = btn.GetList(0, "Menu_id=" + dt.Rows[i]["Menu_id"].ToString(), " convert(int,[Btn_order])");//sqlserver 专用
                    DataSet ds    = btn.GetList(0, "Menu_id=" + dt.Rows[i]["Menu_id"].ToString(), " cast(Btn_order AS signed)");
                    string  roler = "";
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                        {
                            roler += ds.Tables[0].Rows[j]["Btn_id"].ToString() + "|" + ds.Tables[0].Rows[j]["Btn_name"].ToString();
                            roler += ",";
                        }
                    }
                    dt.Rows[i][dt.Columns.Count - 1] = roler;
                }
                string dt1 = "{Rows:[" + GetTasksString(0, dt) + "]}";
                context.Response.Write(dt1);
                context.Response.End();
            }
            //get auth
            if (request["Action"] == "getauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                Model.Sys_authority modelauth = new Model.Sys_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = sa.app;
                modelauth.Menu_ids   = sa.menu;
                modelauth.Button_ids = sa.btn;

                BLL.Sys_authority sysau = new BLL.Sys_authority();

                string  roledata = "0|0";
                DataSet ds       = sysau.GetList("Role_id=" + modelauth.Role_id + " and App_ids='a" + PageValidate.InputText(modelauth.App_ids, int.MaxValue) + ",'");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    DataRow dr = ds.Tables[0].Rows[0];
                    roledata = dr["Menu_ids"] + "|" + dr["Button_ids"];
                }
                context.Response.Write(roledata);
            }
            // save auth
            if (request["Action"] == "saveauth")
            {
                string postdata           = Convert.ToString(HttpContext.Current.Request.QueryString["postdata"]);
                JavaScriptSerializer json = new JavaScriptSerializer();
                save sa = json.Deserialize <save>(postdata);
                Model.Sys_authority modelauth = new Model.Sys_authority();
                modelauth.Role_id    = int.Parse(sa.role_id);
                modelauth.App_ids    = PageValidate.InputText(sa.app, 50);
                modelauth.Menu_ids   = PageValidate.InputText(sa.menu, int.MaxValue);
                modelauth.Button_ids = PageValidate.InputText(sa.btn, int.MaxValue);

                BLL.Sys_authority sysau = new BLL.Sys_authority();

                if (!string.IsNullOrEmpty(postdata))
                {
                    sysau.DeleteWhere("Role_id=" + modelauth.Role_id + " and App_ids='" + PageValidate.InputText(modelauth.App_ids, int.MaxValue) + "'");
                    sysau.Add(modelauth);

                    context.Response.Write("{sucess:sucess}");

                    //日志
                    BLL.Sys_log   log      = new BLL.Sys_log();
                    Model.Sys_log modellog = new Model.Sys_log();

                    DataSet dsemp1 = emp.GetList("id=" + emp_id);
                    modellog.EventDate = DateTime.Now;
                    modellog.UserID    = emp_id;
                    modellog.UserName  = dsemp1.Tables[0].Rows[0]["name"].ToString();
                    modellog.IPStreet  = request.UserHostAddress;

                    modellog.EventType = "权限修改";
                    modellog.EventID   = modelauth.Role_id.ToString();
                    log.Add(modellog);
                }
            }
        }