Esempio n. 1
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            try
            {
                frmNewAttachment frm = new frmNewAttachment();
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    this.Cursor = Cursors.WaitCursor;
                    switch (ENTITY)
                    {
                    case APP_ENTITIES.INVENTORY_ITEM:
                        this.SelectedAttachmentID = (new ServiceInventoryItems()).AddNewInventoryItemsAttachment(
                            this.SelectedEntityID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;

                    case APP_ENTITIES.SALES_LEAD:
                        this.SelectedAttachmentID = (new ServiceSalesLead()).AddNewSalesLeadAttachment(
                            this.SelectedEntityID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;

                    case APP_ENTITIES.SALES_ENQUIRY:
                        this.SelectedAttachmentID = (new ServiceSalesEnquiry()).AddNewSalesEnquiryAttachment(
                            this.SelectedEntityID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;

                    case APP_ENTITIES.SALES_QUOTATION:
                        this.SelectedAttachmentID = (new ServiceSalesQuotation()).AddNewSalesQuotationAttachment(
                            this.SelectedEntityID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;

                    case APP_ENTITIES.SALES_ORDER:

                        this.SelectedAttachmentID = (new ServiceSalesOrder()).AddNewSalesOrderAttachment(
                            this.SelectedEntityID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;

                    case APP_ENTITIES.EMPLOYEES:

                        this.SelectedAttachmentID = (new ServiceEmployee()).AddNewEmployeeAttachment(
                            this.SelectedEntityID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;
                    }
                    this.PopulateDocuments();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ctrlAttachments::btnAddNew_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            this.Cursor = Cursors.Default;
        }
Esempio n. 2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                string serverPath    = string.Empty;
                string strTitle      = string.Empty;
                int    DocCategoryID = 0;

                // GET VALUES TO BE DISPLAYED IN ATTACHMENT EDIT FORM
                switch (this.ENTITY)
                {
                case APP_ENTITIES.SALES_LEAD:
                    TBL_MP_CRM_SM_SalesLead_Attachment objLead = (new ServiceSalesLead()).GetSalesLeadAttachmentDBRecord(SelectedAttachmentID);
                    if (objLead != null)
                    {
                        DocCategoryID = (int)objLead.FK_CategoryID;
                        strTitle      = objLead.Title;
                    }
                    break;

                case APP_ENTITIES.SALES_ENQUIRY:
                    TBL_MP_CRM_SalesEnquiry_Attachments objEnquiry = (new ServiceSalesEnquiry()).GetSalesEnquiryAttachmentDBRecord(SelectedAttachmentID);
                    if (objEnquiry != null)
                    {
                        DocCategoryID = (int)objEnquiry.FK_CategoryID;
                        strTitle      = objEnquiry.Title;
                    }
                    break;

                case APP_ENTITIES.SALES_QUOTATION:
                    TBL_MP_CRM_SalesQuotation_Attachments objQuotation = (new ServiceSalesQuotation()).GetSalesQuotationAttachmentDBRecord(SelectedAttachmentID);
                    if (objQuotation != null)
                    {
                        DocCategoryID = (int)objQuotation.FK_CategoryID;
                        strTitle      = objQuotation.Title;
                    }
                    break;

                case APP_ENTITIES.SALES_ORDER:
                    TBL_MP_CRM_SalesOrder_Attachment objOrder = (new ServiceSalesOrder()).GetSalesOrderAttachmentDBRecord(SelectedAttachmentID);
                    if (objOrder != null)
                    {
                        DocCategoryID = (int)objOrder.FK_CategoryID;
                        strTitle      = objOrder.Title;
                    }
                    break;

                case APP_ENTITIES.INVENTORY_ITEM:
                    TBL_MP_Master_Item_Attachments objItem = (new ServiceInventoryItems()).GetInventoryItemAttachmentDBRecord(SelectedAttachmentID);
                    if (objItem != null)
                    {
                        DocCategoryID = (int)objItem.FK_CategoryID;
                        strTitle      = objItem.Title;
                    }
                    break;

                case APP_ENTITIES.EMPLOYEES:
                    TBL_MP_Master_Employee_Attachment objEmp = (new ServiceEmployee()).GetEmployeeAttachmentDBRecord(SelectedAttachmentID);
                    if (objEmp != null)
                    {
                        DocCategoryID = (int)objEmp.FK_CategoryID;
                        strTitle      = objEmp.Title;
                    }
                    break;
                }

                // OPEN ATTACHMENT FORM FOR EDITING
                frmNewAttachment frm = new frmNewAttachment();
                frm.CategoryID     = DocCategoryID;
                frm.Title          = strTitle;
                frm.OpenForEditing = true;
                if (frm.ShowDialog() == DialogResult.OK)
                {
                    switch (this.ENTITY)
                    {
                    case APP_ENTITIES.SALES_LEAD:
                        (new ServiceSalesLead()).UpdateSalesLeadAttachment(SelectedAttachmentID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;

                    case APP_ENTITIES.SALES_ENQUIRY:
                        (new ServiceSalesEnquiry()).UpdateSalesEnquiryAttachment(SelectedAttachmentID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;

                    case APP_ENTITIES.SALES_QUOTATION:
                        (new ServiceSalesQuotation()).UpdateSalesQuotationAttachment(SelectedAttachmentID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;

                    case APP_ENTITIES.SALES_ORDER:
                        (new ServiceSalesOrder()).UpdateSalesOrderAttachment(SelectedAttachmentID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;

                    case APP_ENTITIES.INVENTORY_ITEM:
                        (new ServiceInventoryItems()).UpdateInventoryItemAttachment(SelectedAttachmentID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;

                    case APP_ENTITIES.EMPLOYEES:
                        (new ServiceEmployee()).UpdateEmployeeAttachment(SelectedAttachmentID, frm.CategoryID, frm.Title, frm.AttachedFilePath, Program.CURR_USER.EmployeeID);
                        break;
                    }
                    this.PopulateDocuments();
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ctrlAttachment::btnEdit_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }