Exemplo n.º 1
0
 private void BindData()
 {
     ManualForm objdata = new ManualForm();
     objdata.GetFormsByManualID(CurrentManual, new Guid(Membership.GetUser().ProviderUserKey.ToString()));
     uiRadGridmanuals.DataSource = objdata.DefaultView;
     uiRadGridmanuals.DataBind();
 }
 private void BindData()
 {
     ManualForm objdata = new ManualForm();
     objdata.GetFormsByManualID(CurrentManual.ManualID);
     uiRadGridmanuals.DataSource = objdata.DefaultView;
     uiRadGridmanuals.DataBind();
 }
        protected void uiRadGridmanuals_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            if (e.CommandName == "EditManual")
            {
                Manual objData = new Manual();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                uiTextBoxTitle.Text = objData.Title;

                CurrentManual = objData;
                uiPanelEdit.Visible = true;
                uiPanelViewAll.Visible = false;
                uiPanelEditVersions.Visible = false;
                uiPanelVersions.Visible = true;
                uiLinkButtonEditForms.Visible = true;
                BindData_Versions();
            }

            else if (e.CommandName == "DeleteManual")
            {
                Manual objData = new Manual();
                objData.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));

                ManualVersion versions = new ManualVersion();
                versions.GetVersionsByManualID(objData.ManualID);
                versions.DeleteAll();
                versions.Save();

                ManualForm forms = new ManualForm();
                forms.GetFormsByManualID(objData.ManualID);
                for (int i = 0; i < forms.RowCount; i++)
                {
                    FromVersion formversions = new FromVersion();
                    formversions.GetVersionsByFormID(forms.ManualFormID);
                    formversions.MarkAsDeleted();
                    formversions.Save();
                }

                forms.DeleteAll();
                forms.Save();

                objData.MarkAsDeleted();
                objData.Save();
                BindData();
            }
        }
        protected void uiButtonSave_Click(object sender, EventArgs e)
        {
            ManualForm objdata = new ManualForm();
            if (CurrentForm == null)
            {
                objdata.AddNew();
                objdata.CreatedBy = new Guid(Membership.GetUser().ProviderUserKey.ToString());
                objdata.CreatedDate = DateTime.Now;
            }
            else
                objdata = CurrentForm;
            objdata.Name = uiTextBoxTitle.Text;
            objdata.ManualID = CurrentManual.ManualID;
            objdata.UpdatedBy = new Guid(Membership.GetUser().ProviderUserKey.ToString());
            objdata.LastUpdatedDate = DateTime.Now;

            objdata.Save();
            BindData();
            CurrentForm = objdata;
            uiPanelViewAll.Visible = false;
            uiPanelVersions.Visible = true;
            uiPanelEditVersions.Visible = false;
            uiPanelEdit.Visible = true;
            //ClearFields();

            // add new notifications
            //SendingNotifications.sendNotif(3, CurrentManual.ManualCategoryID, CurrentManual.ManualID, CurrentForm.ManualFormID);
            ManualCategory cat = new ManualCategory();
            cat.GetTopMostParent(CurrentManual.ManualCategoryID);

            if (CurrentManual.ManualCategoryID == 12)
            {
                SendingNotifications.sendNotif(5, CurrentManual.ManualCategoryID, CurrentManual.ManualID, CurrentForm.ManualFormID, null, null, null, null);
            }
            else
            {
                if (!cat.IsColumnNull(ManualCategory.ColumnNames.ParentCategoryID))
                {
                    if (cat.ParentCategoryID != 12)
                        SendingNotifications.sendNotif(4, CurrentManual.ManualCategoryID, CurrentManual.ManualID, CurrentForm.ManualFormID, null, null, null, null);
                    else
                        SendingNotifications.sendNotif(5, CurrentManual.ManualCategoryID, CurrentManual.ManualID, CurrentForm.ManualFormID, null, null, null, null);
                }
                else
                    SendingNotifications.sendNotif(4, CurrentManual.ManualCategoryID, CurrentManual.ManualID, CurrentForm.ManualFormID, null, null, null, null);
            }

            //SendingNotifications.sendNotif(4, CurrentManual.ManualCategoryID, CurrentManual.ManualID, CurrentForm.ManualFormID,null,null);
        }