コード例 #1
0
        private bool saveData(string strUserID)
        {
            bool   blnResult     = false;
            string strMessage    = string.Empty;
            string strActive     = string.Empty,
                   strCreatedBy  = string.Empty,
                   strUpdatedBy  = string.Empty;
            string     strScript = string.Empty;
            int        i;
            cUser_menu oUser_menu = new cUser_menu();
            cUser      oUser      = new cUser();
            DataSet    ds         = new DataSet();

            try
            {
                string strCanView;
                string strCanInsert;
                string strCanEdit;
                string strCanDelete;
                string strCanApprove;
                string strCanExtra;
                oUser_menu.SP_USER_MENU_DEL(strUserID, ref strMessage);
                for (i = 0; i <= (GridView1.Rows.Count - 1); i++)
                {
                    GridViewRow row           = GridView1.Rows[i];
                    HiddenField hddMenuID     = (HiddenField)row.FindControl("hddMenuID");
                    CheckBox    chkCanView    = (CheckBox)row.FindControl("chkCanView");
                    CheckBox    chkCanInsert  = (CheckBox)row.FindControl("chkCanInsert");
                    CheckBox    chkCanEdit    = (CheckBox)row.FindControl("chkCanEdit");
                    CheckBox    chkCanDelete  = (CheckBox)row.FindControl("chkCanDelete");
                    CheckBox    chkCanApprove = (CheckBox)row.FindControl("chkCanApprove");
                    CheckBox    chkCanExtra   = (CheckBox)row.FindControl("chkCanExtra");
                    string      intMenuId     = hddMenuID.Value;
                    strCanView    = chkCanView.Checked == true ? "Y" : "N";
                    strCanInsert  = chkCanInsert.Checked == true ? "Y" : "N";
                    strCanEdit    = chkCanEdit.Checked == true ? "Y" : "N";
                    strCanDelete  = chkCanDelete.Checked == true ? "Y" : "N";
                    strCanApprove = chkCanApprove.Checked == true ? "Y" : "N";
                    strCanExtra   = chkCanExtra.Checked == true ? "Y" : "N";
                    //if (chkCanView.Checked | chkCanInsert.Checked | chkCanEdit.Checked | chkCanDelete.Checked | chkCanApprove.Checked | chkCanExtra.Checked)
                    //{
                    oUser_menu.SP_USER_MENU_INS(strUserID, intMenuId, strCanView, strCanInsert, strCanEdit, strCanDelete, strCanApprove, strCanExtra, UserLoginName, ref strMessage);
                    // }
                }
                string strperson_group_list = string.Empty;
                for (i = 0; i <= (GridView2.Rows.Count - 1); i++)
                {
                    GridViewRow row            = GridView2.Rows[i];
                    CheckBox    chkPersonGroup = (CheckBox)row.FindControl("chkPersonGroup");
                    if (chkPersonGroup.Checked)
                    {
                        Label lblperson_group_code = (Label)row.FindControl("lblperson_group_code");
                        strperson_group_list += lblperson_group_code.Text + ",";
                    }
                }
                if (strperson_group_list.Length > 0)
                {
                    strperson_group_list = strperson_group_list.Substring(0, strperson_group_list.Length - 1);
                }
                string strdirector_lock = "N";
                if (chkdirector_lock.Checked)
                {
                    strdirector_lock = "Y";
                }
                string strunit_lock = "N";
                if (chkunit_lock.Checked)
                {
                    strunit_lock = "Y";
                }
                oUser.SP_USER_PERSON_GROUP_UPD(strUserID, strperson_group_list, strdirector_lock, strunit_lock, UserLoginName, ref strMessage);
                blnResult = true;
                MsgBox("บันทึกข้อมูลสมบูรณ์");
            }
            catch (Exception ex)
            {
                blnResult     = false;
                lblError.Text = ex.Message.ToString();
            }
            finally
            {
                oUser_menu.Dispose();
            }
            return(blnResult);
        }