Esempio n. 1
0
        protected void btnOverwrite_Click(object sender, EventArgs e)
        {
            if (ViewState["CustomForm"] != null)
            {
                try
                {
                    bool allowOverwrite;

                    CustomFormDTO customForm = (CustomFormDTO)ViewState["CustomForm"];
                    CustomFormDAO cfdao      = new CustomFormDAO(customForm);

                    cfdao.Save(true, out allowOverwrite);
                    panelOverwrite.Visible = false;
                    gvDocTypes.DataBind();
                }
                catch (Exception ex)
                {
                    this.lblMessage.Text   = ex.Message;
                    panelOverwrite.Visible = false;
                }
            }
        }
Esempio n. 2
0
        protected void frmDocTypes_ItemUpdating(object sender, FormViewUpdateEventArgs e)
        {
            if (Page.IsValid)
            {
                bool allowOverwrite = false;
                try
                {
                    string nazwa = ((TextBox)frmDocTypes.FindControl("txtNazwa")).Text;
                    string skrot = ((TextBox)frmDocTypes.FindControl("txtSkrot")).Text;
                    int    catId = int.Parse(ddlDocCatList.SelectedItem.Value);
                    int    docId = int.Parse(gvDocTypes.SelectedDataKey.Value.ToString());

                    bool   isActive         = ((CheckBox)frmDocTypes.FindControl("cbIsActive")).Checked;
                    bool   isLegalAct       = ((CheckBox)frmDocTypes.FindControl("cbAktPrawny")).Checked;
                    bool   isOverwrite      = false;
                    string className        = null;
                    string description      = ((TextBox)frmDocTypes.FindControl("tbDescription")).Text;
                    string oryginalFileName = null;
                    string fileName         = null;

                    //form: false;//
                    bool   isWordFormActive           = ((CheckBox)frmDocTypes.FindControl("wordFormActive")).Checked;
                    string wordOriginalFilename       = null;
                    string wordFilename               = null;
                    string wordSchemaFilename         = null;
                    string wordSchemaOriginalFilename = null;

                    FileUpload fu = (FileUpload)frmDocTypes.FindControl("uploadControl");

                    //form:
                    FileUpload wordForm   = (FileUpload)frmDocTypes.FindControl("wordForm");
                    FileUpload wordSchema = (FileUpload)frmDocTypes.FindControl("wordSchema");

                    if (fu != null && fu.HasFile)
                    {
                        oryginalFileName = Path.GetFileName(fu.PostedFile.FileName);
                        fileName         = SaveFile(fu);
                    }

                    //form:
                    if (wordForm != null && wordForm.HasFile)
                    {
                        wordOriginalFilename = Path.GetFileName(wordForm.PostedFile.FileName);
                        wordFilename         = SaveFile(wordForm);
                    }

                    if (wordSchema != null && wordSchema.HasFile)
                    {
                        wordSchemaOriginalFilename = Path.GetFileName(wordSchema.PostedFile.FileName);
                        wordSchemaFilename         = SaveFile(wordSchema);
                    }

                    CustomFormDTO customForm = new CustomFormDTO(docId, catId, nazwa, skrot, true, isLegalAct, fileName, oryginalFileName, isActive, className, description, wordFilename, wordOriginalFilename, wordSchemaFilename, wordSchemaOriginalFilename, isWordFormActive);

                    ViewState["CustomForm"] = customForm;

                    CustomFormDAO cfdao = new CustomFormDAO(customForm);

                    cfdao.Save(isOverwrite, out allowOverwrite);

                    panelDocTypes.Visible = false;
                    gvDocTypes.DataBind();
                }
                catch (Exception ex)
                {
                    if (allowOverwrite)
                    {
                        panelOverwrite.Visible   = true;
                        panelDocTypes.Visible    = false;
                        lblOverwriteMessage.Text = ex.Message;
                    }
                    else
                    {
                        lblMessage.Text        = ex.Message;
                        panelOverwrite.Visible = false;
                    }
                }
            }
        }