示例#1
0
        protected void RadDataFormUser_ItemEditing(object sender, Telerik.Web.UI.RadDataFormCommandEventArgs e)
        {
            RadDataFormEditableItem editedItem = e.DataFormItem as RadDataFormEditableItem;
            Hashtable newValues = new Hashtable();

            editedItem.ExtractValues(newValues);
            var user = _db.Users.Where(u => u.userId == userId).FirstOrDefault();

            user.firstname = newValues["firstname"].ToString();
            user.lastname  = newValues["lastname"].ToString();
            _db.SaveChanges();
        }
示例#2
0
    protected void RadDataForm1_ItemInserting(object sender, Telerik.Web.UI.RadDataFormCommandEventArgs e)
    {
        RadDataFormEditableItem insertedItem = e.DataFormItem as RadDataFormEditableItem;
        Hashtable newValues = new Hashtable();

        insertedItem.ExtractValues(newValues);


        try
        {
            RadComboBox RadItemDpdDpt3     = (RadComboBox)insertedItem.FindControl("RadItemDpdDpt3");
            RadComboBox RadItemDpdBrch3    = (RadComboBox)insertedItem.FindControl("RadItemDpdBrch3");
            CheckBox    IsActionOwnerChk2s = (CheckBox)insertedItem.FindControl("IsActionOwnerChk2");
            string      email     = newValues["EMAIL"].ToString();
            string      lastname  = PropCase(newValues["LastName"].ToString());
            string      username  = newValues["USER_NAME"].ToString();
            string      FirstName = PropCase(newValues["FirstName"].ToString());

            int  deptid            = Convert.ToInt32(RadItemDpdDpt3.SelectedValue);
            int  brchid            = Convert.ToInt32(RadItemDpdBrch3.SelectedValue);
            bool IsActionOwnerChk2 = IsActionOwnerChk2s.Checked;
            if (IsActionOwnerChk2 == true)
            {
                IsActionOwnerChkss = "Yes";
            }
            else
            {
                IsActionOwnerChkss = "No";
            }

            qry = "INSERT INTO USERS(DEPARTMENTID,BRANCHID,USER_NAME,EMAIL,LASTNAME,FIRSTNAME,IsActionOwner)VALUES(" + Convert.ToInt32(RadItemDpdDpt3.SelectedValue) + ", " + Convert.ToInt32(RadItemDpdBrch3.SelectedValue) + ",'" + newValues["USER_NAME"].ToString() + "','" + newValues["EMAIL"].ToString() + "','" + PropCase(newValues["LastName"].ToString()) + "','" + PropCase(newValues["FirstName"].ToString()) + "','" + IsActionOwnerChkss + "')";
            con.SqlDs(qry, 1);
        }
        catch (Exception ex)
        {
            con.insertError(ex.Message);
            e.Canceled = true;
        }
        LoadDataForRadGrid1();
        RadGrid1.DataBind();
    }
示例#3
0
    protected void RadDataForm1_ItemUpdating(object sender, Telerik.Web.UI.RadDataFormCommandEventArgs e)
    {
        RadDataFormEditableItem editedItem = e.DataFormItem as RadDataFormEditableItem;
        Hashtable newValues = new Hashtable();

        editedItem.ExtractValues(newValues);

        DataTable productsTable = SourceDataTable;

        DataRow[] changedRows = productsTable.Select("USER_NAME = '" + editedItem.GetDataKeyValue("USER_NAME") + "'");

        if (changedRows.Length != 1)
        {
            e.Canceled = true;
            return;
        }
        try
        {
            RadComboBox RadItemDpdDpt2    = (RadComboBox)editedItem.FindControl("RadItemDpdDpt2");
            RadComboBox RadItemDpdBrch2   = (RadComboBox)editedItem.FindControl("RadItemDpdBrch2");
            CheckBox    ResetPassCheckBox = (CheckBox)editedItem.FindControl("ResetPassCheckBox1");
            CheckBox    IsActionOwnerChk  = (CheckBox)editedItem.FindControl("IsActionOwnerChk1");
            string      email             = newValues["EMAIL"].ToString();
            string      lastname          = newValues["LastName"].ToString();
            string      username          = newValues["USER_NAME"].ToString();
            string      FirstName         = newValues["FirstName"].ToString();
            int         id                = Convert.ToInt32(newValues["USERID"]);
            int         deptid            = Convert.ToInt32(RadItemDpdDpt2.SelectedValue);
            int         brchid            = Convert.ToInt32(RadItemDpdBrch2.SelectedValue);
            bool        chkedpass         = ResetPassCheckBox.Checked;
            bool        IsActionOwnerChks = IsActionOwnerChk.Checked;
            if (IsActionOwnerChks == true)
            {
                IsActionOwnerChkss = "Yes";
            }
            else
            {
                IsActionOwnerChkss = "No";
            }
            if (chkedpass == true)
            {
                passwords = Users.Users.Encrypt("123456", true);
                foreach (DictionaryEntry entry in newValues)
                {
                    qrys = "UPDATE USERS SET IsActionOwner='" + IsActionOwnerChkss + "',PASSWORD='******', DEPARTMENTID=" + Convert.ToInt32(RadItemDpdDpt2.SelectedValue) + ",  BRANCHID=" + Convert.ToInt32(RadItemDpdBrch2.SelectedValue) + ", USER_NAME=  '" + newValues["USER_NAME"].ToString() + "',EMAIL= '" + newValues["EMAIL"].ToString() + "',LASTNAME= '" + PropCase(newValues["LastName"].ToString()) + "',FIRSTNAME= '" + PropCase(newValues["FirstName"].ToString()) + "' WHERE USERID=" + Convert.ToInt32(newValues["USERID"]) + "";
                    con.SqlDs(qrys, 1);
                }
            }
            else
            {
                foreach (DictionaryEntry entry in newValues)
                {
                    qrys = "UPDATE USERS SET IsActionOwner='" + IsActionOwnerChkss + "',DEPARTMENTID=" + Convert.ToInt32(RadItemDpdDpt2.SelectedValue) + ",  BRANCHID=" + Convert.ToInt32(RadItemDpdBrch2.SelectedValue) + ", USER_NAME=  '" + newValues["USER_NAME"].ToString() + "',EMAIL= '" + newValues["EMAIL"].ToString() + "',LASTNAME= '" + PropCase(newValues["LastName"].ToString()) + "',FIRSTNAME= '" + PropCase(newValues["FirstName"].ToString()) + "' WHERE USERID=" + Convert.ToInt32(newValues["USERID"]) + "";
                    con.SqlDs(qrys, 1);
                }
            }
        }
        catch (Exception ex)
        {
            con.insertError(ex.Message);
            changedRows[0].CancelEdit();
            e.Canceled = true;
        }
        LoadDataForRadGrid1();
        RadGrid1.DataBind();
    }