Exemplo n.º 1
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            HR_ORG valObj = new HR_ORG();
            //if(txtORG_ID.Value !="" )

            if(txtORG_NAME.Value !="" )
                valObj.ORG_NAME = Convert.ToString(txtORG_NAME.Value);

            valObj.P_ORG_ID = wucSelORG1.ORG_ID;
            valObj.SORT_NO = Convert.ToInt32(txtSortNum.Value);

            if (txtSNAME.Value != "")
                valObj.SNAME = Convert.ToString(txtSNAME.Value);

            if (txtRNAME.Value != "")
                valObj.RNAME = Convert.ToString(txtRNAME.Value);

            if (txtEXP1.Value != "")
                valObj.EXP1 = Convert.ToString(txtEXP1.Value);

            if (txtEXP2.Value != "")
                valObj.EXP2 = Convert.ToString(txtEXP2.Value);

            if (txtEXP3.Value != "")
                valObj.EXP3 = Convert.ToString(txtEXP3.Value);

            if (keyid != "")
            {
                valObj.ORG_ID =keyid;
                count = ORGHelper.EditORG(valObj);// BLLTable<HR_ORG>.Factory(conn).Update(valObj, HR_ORG.Attribute.ORG_ID);
            }
            else
            {
                //count = BLLTable<HR_ORG>.Factory(conn).Insert(valObj);
                keyid = ORGHelper.AddORG(valObj, valObj.P_ORG_ID);// valObj.ORG_ID.ToString();
                count = keyid != "" ? 1 : 0;
            }
            if (count > 0)
            {
                StringBuilder sbData = new StringBuilder("({valObj:''");
                List<AttributeItem> lstCol = valObj.af_AttributeItemList;
                for (int i = 0; i < lstCol.Count; i++)
                {
                    object val = valObj.GetValue(lstCol[i]);
                    if (val != null)
                    {
                        sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'");
                    }
                }
                sbData.Append("})");
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true);
            }
        }
        catch (Exception ex)
        {
            litWarn.Text = ex.Message;
        }
    }
Exemplo n.º 2
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            HR_ORG valObj = new HR_ORG();
            //if(txtORG_ID.Value !="" )

            if (txtORG_NAME.Value != "")
            {
                valObj.ORG_NAME = Convert.ToString(txtORG_NAME.Value);
            }

            valObj.P_ORG_ID = wucSelORG1.ORG_ID;
            valObj.SORT_NO  = Convert.ToInt32(txtSortNum.Value);

            if (txtSNAME.Value != "")
            {
                valObj.SNAME = Convert.ToString(txtSNAME.Value);
            }


            if (txtRNAME.Value != "")
            {
                valObj.RNAME = Convert.ToString(txtRNAME.Value);
            }

            if (txtEXP1.Value != "")
            {
                valObj.EXP1 = Convert.ToString(txtEXP1.Value);
            }


            if (txtEXP2.Value != "")
            {
                valObj.EXP2 = Convert.ToString(txtEXP2.Value);
            }


            if (txtEXP3.Value != "")
            {
                valObj.EXP3 = Convert.ToString(txtEXP3.Value);
            }

            if (keyid != "")
            {
                valObj.ORG_ID = keyid;
                count         = ORGHelper.EditORG(valObj);// BLLTable<HR_ORG>.Factory(conn).Update(valObj, HR_ORG.Attribute.ORG_ID);
            }
            else
            {
                //count = BLLTable<HR_ORG>.Factory(conn).Insert(valObj);
                keyid = ORGHelper.AddORG(valObj, valObj.P_ORG_ID);// valObj.ORG_ID.ToString();
                count = keyid != "" ? 1 : 0;
            }
            if (count > 0)
            {
                StringBuilder        sbData = new StringBuilder("({valObj:''");
                List <AttributeItem> lstCol = valObj.af_AttributeItemList;
                for (int i = 0; i < lstCol.Count; i++)
                {
                    object val = valObj.GetValue(lstCol[i]);
                    if (val != null)
                    {
                        sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'");
                    }
                }
                sbData.Append("})");
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true);
            }
        }
        catch (Exception ex)
        {
            litWarn.Text = ex.Message;
        }
    }
Exemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //在列表里点击删除按钮,通过AJAX执行这里的后台代码,删除一条记录
        if (Request["USER_ID"] != null && Request["delFromUserRole"] != null)
        {
            SYS_USERDATA delCond = new SYS_USERDATA();
            delCond.USER_ID   = decimal.Parse(Request["USER_ID"]);
            delCond.DATA_TYPE = Request["Data_Type"];
            delCond.In(SYS_USERDATA.Attribute.DATA_ID, Request["delFromUserRole"]);

            BLLTable <SYS_USERDATA> .Factory(conn).Delete(delCond);

            Response.Write("{}");
        }
        if (Request["USER_ID"] != null && Request["AddToUserData"] != null)
        {
            SYS_USERDATA valObj = new SYS_USERDATA();
            valObj.USER_ID = decimal.Parse(Request["USER_ID"]);
            string datatype = Request["Data_Type"];
            valObj.DATA_TYPE = datatype;
            string[] arrDataID = null;
            string   dataid    = Request["AddToUserData"];
            if (dataid.IndexOf(",") == -1)
            {
                arrDataID = new string[] { dataid };
            }
            else
            {
                arrDataID = dataid.Split(',');
            }
            if (valObj.DATA_ID != "0")
            {
                SYS_USERDATA delCond = new SYS_USERDATA();
                delCond.USER_ID   = valObj.USER_ID;
                delCond.DATA_TYPE = datatype;
                BLLTable <SYS_USERDATA> .Factory(conn).Delete(delCond);
            }

            StringBuilder sbData = new StringBuilder("[");
            for (int a = 0; a < arrDataID.Length; a++)
            {
                valObj.DATA_ID = arrDataID[a];

                if (!BLLTable <SYS_USERDATA> .Exists(valObj))
                {
                    int re = BLLTable <SYS_USERDATA> .Factory(conn).Insert(valObj);

                    if (re > 0)
                    {
                        if (sbData.Length > 1)
                        {
                            sbData.Append(",");
                        }
                        sbData.Append("{valObj:''");

                        if (datatype.IndexOf("HR_ORG") != -1)
                        {
                            #region//
                            HR_ORG valORG = BLLTable <HR_ORG> .Factory(conn).GetRowData(HR_ORG.Attribute.ORG_ID, valObj.DATA_ID);

                            List <AttributeItem> lstCol = valORG.af_AttributeItemList;
                            for (int i = 0; i < lstCol.Count; i++)
                            {
                                object val = valORG.GetValue(lstCol[i]);
                                if (val != null)
                                {
                                    sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'");
                                }
                            }
                            #endregion
                        }
                        else if (datatype.IndexOf("HR_DEPT") != -1)
                        {
                            #region//
                            HR_DEPT valORG = BLLTable <HR_DEPT> .Factory(conn).GetRowData(HR_DEPT.Attribute.DEPT_ID, valObj.DATA_ID);

                            List <AttributeItem> lstCol = valORG.af_AttributeItemList;
                            for (int i = 0; i < lstCol.Count; i++)
                            {
                                object val = valORG.GetValue(lstCol[i]);
                                if (val != null)
                                {
                                    sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'");
                                }
                            }
                            #endregion
                        }
                        else if (datatype.IndexOf("IM_STORAGE") != -1)
                        {
                            #region//
                            IM_STORAGE valORG = BLLTable <IM_STORAGE> .Factory(conn).GetRowData(IM_STORAGE.Attribute.STOR_ID, valObj.DATA_ID);

                            List <AttributeItem> lstCol = valORG.af_AttributeItemList;
                            for (int i = 0; i < lstCol.Count; i++)
                            {
                                object val = valORG.GetValue(lstCol[i]);
                                if (val != null)
                                {
                                    sbData.Append(",").Append(lstCol[i].FieldName).Append(":'").Append(val.ToString()).Append("'");
                                }
                            }
                            #endregion
                        }
                        sbData.Append("}");
                    }
                }
            }
            sbData.Append("]");
            Response.Write(sbData.ToString());
        }

        //在列表顶部点击删除按钮,通过AJAX执行这里的后台代码,删除多条记录
        if (Request["DelKeyIDS"] != null)
        {
            if (Request["USER_ID"] != null)
            {
                SYS_USERDATA cond = new SYS_USERDATA();
                cond.In(SYS_USERDATA.Attribute.DATA_ID, Request["DelKeyIDS"]);
                cond.DATA_TYPE = Request["Data_Type"];
                cond.USER_ID   = decimal.Parse(Request["USER_ID"]);
                int re = BLLTable <SYS_USERDATA> .Factory(conn).Delete(cond);

                if (re > 0)
                {
                    Response.Write("1");//可以输出数字 大于0 表示操作成功,也可以直接输出 字符串,客户端将弹出此字符串信息作为提示
                }
                else
                {
                    Response.Write("删除失败!");
                }
            }
            else
            {
                SYS_USERDATA cond = new SYS_USERDATA();
                cond.In(SYS_USERDATA.Attribute.USER_ID, Request["DelKeyIDS"]);
                int re = BLLTable <SYS_USERDATA> .Factory(conn).Delete(cond);

                if (re > 0)
                {
                    Response.Write("1");//可以输出数字 大于0 表示操作成功,也可以直接输出 字符串,客户端将弹出此字符串信息作为提示
                }
                else
                {
                    Response.Write("删除失败!");
                }
            }
        }

        //在用户详细信息查看编辑页面,点保存时,通过AJAX执行这里的后台代码,实现部门字段的更新
        if (Request["saveInfo"] != null)
        {
            SYS_USERDATA val = new SYS_USERDATA();
            val.USER_ID = int.Parse(Request["FieldKeyID"]);
            List <AttributeItem> lstCol = val.af_AttributeItemList;
            for (int i = 0; i < lstCol.Count; i++)
            {
                if (!string.IsNullOrEmpty(Request["txt" + lstCol[i].FieldName]))
                {
                    val.SetValue(lstCol[i].FieldName, Request["txt" + lstCol[i].FieldName]);
                }
            }

            BLLTable <SYS_USERDATA> .Factory(conn).Update(val, SYS_USERDATA.Attribute.USER_ID);

            Response.Write("修改用户信息成功");
        }
        Response.End();
    }