Ejemplo n.º 1
0
        /// <summary>
        /// Save Or edit function, here checking the invalid entries
        /// </summary>
        public void SaveOrEditFunction()
        {
            try
            {
                bool isOk = true;
                if (isOk)
                    if (txtvoucherNo.Text == string.Empty)
                    {
                        Messages.InformationMessage("Enter voucher no");
                        txtvoucherNo.Focus();
                    }
                    else if (txtVoucherDate.Text == string.Empty)
                    {
                        Messages.InformationMessage("Select date");
                        txtVoucherDate.Focus();
                    }
                    else if (cmbvouchertype.SelectedValue == null)
                    {
                        Messages.InformationMessage("Select voucher type");
                        cmbvouchertype.Focus();
                    }
                    else if (cmbInvoiceNo.SelectedValue == null)
                    {
                        Messages.InformationMessage("Select against invoice no");
                        cmbInvoiceNo.Focus();
                    }
                    else if (cmbStatus.Text == string.Empty)
                    {
                        Messages.InformationMessage("Select status");
                        cmbStatus.Focus();
                    }
                    else
                    {
                        if (PublicVariables.isMessageAdd)
                        {
                            isOk = false;
                            PDCClearanceMasterSP sppdcClerance = new PDCClearanceMasterSP();
                            if (!isInEditMode)
                            {
                                if (Messages.SaveMessage())
                                    if (!sppdcClerance.PDCclearanceCheckExistence(txtvoucherNo.Text.Trim(), decPDCclearanceVoucherTypeId, 0))
                                    {
                                        SaveFunction();
                                    }
                                    else
                                    {
                                        Messages.InformationMessage("Voucher number already exist");
                                    }
                            }
                            else if (isInEditMode)
                            {
                                if (Messages.UpdateMessage())
                                {
                                    SaveFunction();
                                }
                            }
                        }
                        if (isOk)
                        {
                            if (CheckUserPrivilege.PrivilegeCheck(PublicVariables._decCurrentUserId, this.Name, btnSave.Text))
                            {
                                PDCPayableMasterSP SpPDCpayable = new PDCPayableMasterSP();

                                if (isInEditMode)
                                {
                                    SaveFunction();
                                }
                                else
                                {
                                    SaveFunction();
                                }
                            }
                            else
                            {
                                Messages.NoPrivillageMessage();
                            }
                        }
                    }
            }
            catch (Exception ex)
            {
                MessageBox.Show("PC10:" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }