Ejemplo n.º 1
0
    public void Attach()
    {
        string filename = Path.GetFileName(fuAttachment.FileName);
        string fullPath = path + filename;
        MaterialFacade facade = new MaterialFacade();
        if (hfId.Value != null)
        {
            if (fuAttachment.PostedFile != null)
            {
                HttpPostedFile myFile = fuAttachment.PostedFile;

                int nFileLen = myFile.ContentLength;
                byte[] myData = new byte[nFileLen];
                myFile.InputStream.Read(myData, 0, nFileLen);
                WriteToFile(fullPath, ref myData);
                facade.UpdateAttachment(Convert.ToInt32(hfId.Value), filename);
                gvMaterials.DataBind();
            }
        }
    }
Ejemplo n.º 2
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        MaterialFacade facade = new MaterialFacade();
        int? id = null;
        decimal? nullValue = null;
        try
        {
            id = (!String.IsNullOrEmpty(hfId.Value)) ? Convert.ToInt32(hfId.Value) : id;
            facade.Save(id, txtMaterialCode.Text, txtMaterialName.Text, txtDescription.Text, (!String.IsNullOrEmpty(txtPricePerUnit.Text)) ? Convert.ToDecimal(txtPricePerUnit.Text) : nullValue
                , (!String.IsNullOrEmpty(hfAttachment.Value) ? hfAttachment.Value : null)
                        , DateTime.Now, DateTime.Now, user, user);
            lblErrorMessage.Text = Helper.SaveRecordMessage(true);
        }
        catch (Exception ex)
        {
            lblErrorMessage.Text = Helper.SaveRecordMessage(false);

        }

        gvMaterials.DataBind();
        Helper.EnableControls(false, action);
        fuAttachment.Visible = false;
        btnUpload.Visible = false;
    }