Beispiel #1
0
        /// <summary>
        /// SaveForEdit
        /// </summary>
        /// <param name="viewId">viewId</param>
        /// <param name="loginId">loginId</param>
        /// <param name="name">name</param>
        /// <param name="type">type</param>
        /// <param name="logic">logic</param>
        /// <param name="sqlCommand">sqlCommand</param>
        /// <param name="fmType">fmType</param>
        /// <param name="companyId">companyId</param>
        public void SaveForEdit(int viewId, int loginId, string name, string type, string logic, string sqlCommand, string fmType, int companyId, string newName, string newType)
        {
            FmViewGateway fmViewGateway = new FmViewGateway();
            fmViewGateway.LoadByViewId(viewId, companyId);

            int originalViewId = viewId;
            int originalLoginId = fmViewGateway.GetLoginId(viewId);
            string originalName = fmViewGateway.GetName(viewId);
            string originalType = fmViewGateway.GetType(viewId);
            string originalLogic = fmViewGateway.GetLogic(viewId);
            string originalSqlCommand = fmViewGateway.GetSqlCommand(viewId);
            string originalFmType = fmViewGateway.GetFmType(viewId);
            bool originalDeleted = fmViewGateway.GetDeleted(viewId);
            int originalCompanyId = fmViewGateway.GetCompanyId(viewId);

            UpdateDirect(originalViewId, originalLoginId, originalName, originalType, originalLogic, originalSqlCommand, originalFmType, originalDeleted, originalCompanyId, viewId, loginId, newName, newType, logic, sqlCommand, fmType, false, companyId);
        }
        private bool StepConditionsNext()
        {
            // Validate data
            bool validData = true;

            // Edit if there is data to save
            Page.Validate("ConditionsUpdate");
            if (!Page.IsValid) validData = false;

            if (validData)
            {
                // Conditions Gridview, if the gridview is edition mode
                if (grdConditions.EditIndex >= 0)
                {
                    grdConditions.UpdateRow(grdConditions.EditIndex, true);
                    grdConditions.DataBind();
                }
            }

            Page.Validate("ConditionsNext");
            if (!Page.IsValid) validData = false;

            if (validData)
            {
                // Add conditions if exists at footer
                if (ValidateFooterNext())
                {
                    GrdConditionsAdd();
                }
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int viewId = Int32.Parse(hdfViewId.Value);

                FmViewGateway fmViewGateway = new FmViewGateway();
                fmViewGateway.LoadByViewId(viewId, companyId );

                fmViewConditionTemp.Rows.Clear();

                // Create dataset
                FmViewTDS dataSet = new FmViewTDS();
                dataSet.FmViewConditionNew.Merge(fmViewConditionNew, true);
                dataSet.FmViewConditionTemp.Merge(fmViewConditionTemp, true);

                // Process conditions
                FmViewConditionTemp model = new FmViewConditionTemp(dataSet);
                FmViewConditionNew modelLogic = new FmViewConditionNew(dataSet);

                string originalLogic = fmViewGateway.GetLogic(viewId);
                string newLogic = modelLogic.GetConditionsByDefault();

                ArrayList aConditions = new ArrayList();
                aConditions = modelLogic.GetConditions();

                bool isConditionsUpdate = false;

                if (originalLogic.Trim() != newLogic.Trim())
                {
                    foreach (string conditionNumber in aConditions)
                    {
                        if (!originalLogic.Contains(conditionNumber))
                        {
                            isConditionsUpdate = true;
                        }
                    }

                    if (!isConditionsUpdate)
                    {
                        if (Session["conditionsUpdate"] != null)
                        {
                            if (Session["conditionsUpdate"].ToString() == "true")
                            {
                                isConditionsUpdate = true;
                            }
                        }
                    }
                }
                else
                {
                    tbxLogic.Text = originalLogic.Trim();
                }

                if (isConditionsUpdate)
                {
                    tbxLogic.Text = newLogic.Trim();
                }
                else
                {
                    tbxLogic.Text = originalLogic.Trim();
                }

                // Get changes
                fmViewConditionNew.Rows.Clear();
                fmViewConditionNew.Merge(modelLogic.Table);
                fmViewConditionTemp.Rows.Clear();
                fmViewConditionTemp.Merge(model.Table);

                // Store tables
                Session.Remove("fmViewConditionNewDummy");
                Session.Remove("fmViewConditionTempDummy");
                Session["fmViewConditionNew"] = fmViewConditionNew;
                Session["fmViewConditionTemp"] = fmViewConditionTemp;

                Session["conditionsUpdate"] = null;

                return true;
            }
            else
            {
                return false;
            }
        }