Example #1
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            SYS_APP valObj = new SYS_APP();

            if(txtAPP_ID.Value !="" )
                valObj.APP_ID = Convert.ToString(txtAPP_ID.Value);

            if(txtAPP_NAME.Value !="" )
                valObj.APP_NAME = Convert.ToString(txtAPP_NAME.Value);

            if(txtAPP_LABEL.Value !="" )
                valObj.APP_LABEL = Convert.ToString(txtAPP_LABEL.Value);

            if(txtDEFAULT_URL.Value !="" )
                valObj.DEFAULT_URL = Convert.ToString(txtDEFAULT_URL.Value);

            if(txtDEFAULT_URL_NAME.Value !="" )
                valObj.DEFAULT_URL_NAME = Convert.ToString(txtDEFAULT_URL_NAME.Value);

            if(txtIsBigSystem.Value !="" )
                valObj.IsBigSystem = Convert.ToBoolean(txtIsBigSystem.Value);

            if(txtNote.Value !="" )
                valObj.Note = Convert.ToString(txtNote.Value);

            valObj.APP_IMG =  hidtxtAPP_IMG.Value;

            if (keyid != "")
            {
                valObj.APP_ID = Convert.ToString(keyid);
                count = BLLTable<SYS_APP>.Factory(conn).Update(valObj, SYS_APP.Attribute.APP_ID);
            }
            else
            {
                count = BLLTable<SYS_APP>.Factory(conn).Insert(valObj, SYS_APP.Attribute.APP_ID);
                keyid = valObj.APP_ID.ToString();

            }
            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("}");
                if (ViewState["sbData"] == null)
                {
                    ViewState["sbData"] = sbData.ToString();
                }
                else {
                    ViewState["sbData"] += ","+sbData.ToString();
                }
                Button btn = (Button)sender;
                if (btn.ID.IndexOf("btnOK")!=-1)
                {
                    if (ViewState["sbData"] == null)
                    {
                        string dataStr = "[" + ViewState["sbData"].ToString() + "]";
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = '" + dataStr + "';}else{window.returnValue = '" + dataStr + "';}window.close();", true);
                    }
                    else
                    {
                        ScriptManager.RegisterStartupScript(Page, this.GetType(), "goto", "if (window.opener){window.opener.returnValue = 're';}else{window.returnValue = 're';}window.close();", true);
                    }
                }
                else
                {

                    txtAPP_ID.Value ="";

                    txtAPP_NAME.Value ="";

                    txtAPP_LABEL.Value ="";

                    txtDEFAULT_URL.Value ="";

                    txtDEFAULT_URL_NAME.Value ="";

                    txtIsBigSystem.Value ="";

                    txtNote.Value ="";

                    txtAPP_IMG.Src ="";
                }
            }
        }
        catch (Exception ex)
        {
            litWarn.Text = ex.Message;
        }
    }