Пример #1
0
        /// <summary>
        /// SaveForm
        /// </summary>
        /// <returns></returns>
        public bool SaveForm()
        {
            try
            {
                this.Cursor  = Cursors.WaitCursor;
                formCtrlData = this.loader.Save();

                if (formCtrlData != null && formCtrlData.Count > 0)
                {
                    string strFormCode = string.Empty;
                    string strFormName = string.Empty;

                    strFormCode = this.txtEfCode.Text.Trim();
                    if (string.IsNullOrEmpty(strFormCode))
                    {
                        DialogBox.Msg("请输申请单编码。", MessageBoxIcon.Exclamation);
                        this.txtEfCode.Focus();
                        return(false);
                    }

                    strFormName = this.txtEfName.Text.Trim();
                    if (string.IsNullOrEmpty(strFormName))
                    {
                        DialogBox.Msg("请输入申请单名称。", MessageBoxIcon.Exclamation);
                        this.txtEfName.Focus();
                        return(false);
                    }
                    int intVersion = Function.Int(this.cboVersion.Text);
                    if (intVersion == 0)
                    {
                        DialogBox.Msg("请输入版本号。", MessageBoxIcon.Exclamation);
                        this.cboVersion.Focus();
                        return(false);
                    }
                    int intStatus = this.cboEfStatus.SelectedIndex;

                    List <string> lstCtrl = new List <string>();
                    foreach (EntityFormCtrl ctrl in formCtrlData)
                    {
                        if (!string.IsNullOrEmpty(ctrl.ItemName))
                        {
                            if (lstCtrl.IndexOf(ctrl.ItemName) < 0)
                            {
                                lstCtrl.Add(ctrl.ItemName);
                            }
                            else
                            {
                                DialogBox.Msg("存在同名的控件名称:" + ctrl.ItemCaption + "(" + ctrl.ItemName + "),请修正。", MessageBoxIcon.Exclamation);
                                return(false);
                            }
                        }
                        else
                        {
                            if (Function.Int(ctrl.ItemType) > 0)
                            {
                                DialogBox.Msg("请录入项目代码:" + ctrl.ItemCaption, MessageBoxIcon.Exclamation);
                                return(false);
                            }
                        }
                    }

                    try
                    {
                        // 1.
                        EntityFormDesign formVo = new EntityFormDesign();
                        formVo.Formid          = FormId;
                        formVo.Formcode        = strFormCode;
                        formVo.Formname        = strFormName;
                        formVo.Formtype        = this.FormType;
                        formVo.Version         = intVersion;
                        formVo.Pycode          = SpellCodeHelper.GetPyCode(strFormName);
                        formVo.Wbcode          = SpellCodeHelper.GetWbCode(strFormName);
                        formVo.Recorderid      = GlobalLogin.objLogin.EmpNo;
                        formVo.RecorderName    = GlobalLogin.objLogin.EmpName;
                        formVo.Status          = intStatus;
                        formVo.Printtemplateid = this.PrintTemplateId;

                        int heightCtrl = 0;
                        foreach (EntityFormCtrl item in formCtrlData)
                        {
                            heightCtrl = Math.Max(item.Top, heightCtrl);
                        }
                        formVo.Panelsize = Convert.ToString(heightCtrl + 50) + "|" + pnlDesignPanel.Width.ToString();
                        // 2.
                        formVo.Layout = FormTool.LayoutXml(formCtrlData);

                        int             intAppFid = 0;
                        ProxyFormDesign proxy     = new ProxyFormDesign();
                        formVo.Recorddate = Common.Utils.Utils.ServerTime();

                        #region 一般表单处理

                        if (proxy.Service.SaveForm(formVo, out intAppFid) > 0)
                        {
                            if (this.FormId <= 0)
                            {
                                NewFlag = true;
                            }
                            else
                            {
                                if (!NewFlag)
                                {
                                    UpdateFlag = true;
                                }
                            }
                            this.ValueChanged = false;
                            this.FormId       = intAppFid;

                            if (wrapper != null)
                            {
                                wrapper.FormId = this.FormId;
                            }

                            bool isExsit = false;
                            int  count   = this.cboVersion.Properties.Items.Count;
                            for (int i = 0; i < count; i++)
                            {
                                if (this.cboVersion.Properties.Items[i].ToString() == formVo.Version.ToString())
                                {
                                    IsExists = true;
                                    break;
                                }
                            }
                            if (!isExsit)
                            {
                                this.cboVersion.Properties.Items.Add(formVo.Version.ToString());
                            }

                            this.IsSave = true;
                            DialogBox.Msg("保存表单成功!", MessageBoxIcon.Exclamation);
                            this.ValueChanged = false;
                            return(true);
                        }
                        else
                        {
                            DialogBox.Msg("保存表单失败。", MessageBoxIcon.Exclamation);
                        }
                        #endregion
                    }
                    catch (Exception e)
                    {
                        DialogBox.Msg(e.Message);
                        return(false);
                    }
                }
                else
                {
                    DialogBox.Msg("请制作表单。", MessageBoxIcon.Information);
                }
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
            return(false);
        }
Пример #2
0
 /// <summary>
 /// LayoutXML
 /// </summary>
 /// <returns></returns>
 public string LayoutXML()
 {
     LayoutXML(this.ControlContainer);
     return(FormTool.LayoutXml(FormCtrls));
 }