Esempio n. 1
0
        private void FillAssetMaintype()
        {
            clsMasters clsMaster         = null;
            DataTable  dtAssetMainMaster = null;

            try
            {
                clsMaster         = new clsMasters();
                dtAssetMainMaster = clsMaster.GetAssetMainMasterType(1);
                DataRow dr = dtAssetMainMaster.NewRow();
                dr["nAssetMainTypeID"] = 0;
                dr["sAssetType"]       = "";
                dtAssetMainMaster.Rows.InsertAt(dr, 0);

                cmbAssetMainType.DataSource    = dtAssetMainMaster;
                cmbAssetMainType.DisplayMember = "sAssetType";
                cmbAssetMainType.ValueMember   = "nAssetMainTypeID";
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString(), clsGlobal._sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                if (clsMaster != null)
                {
                    clsMaster = null;
                }
            }
        }
Esempio n. 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtMainTypeName.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter " + lblFormHeader.Text + ".", sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMainTypeName.Focus();
                return;
            }
            if (txtMasterCode.Text.Trim() == "")
            {
                MessageBox.Show("Please Enter Code for " + lblFormHeader.Text + ".", sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMasterCode.Focus();
                return;
            }
            switch (MasterType)
            {
            case MasterType.AssetType:
            case MasterType.AssetType1:
            {
                if (Convert.ToInt64(cmbAssetMainType.SelectedValue) == 0)
                {
                    MessageBox.Show("Please Select Main Asset Type.", sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtMainTypeName.Focus();
                    return;
                }
                break;
            }
            }
            clsMasters clsMaster = null;

            try
            {
                bool bIsAllowAccess    = false;
                bool bIsAllowSignatory = false;
                if (rdAllowAccessYes.Checked)
                {
                    bIsAllowAccess = true;
                }
                else if (rdAllowAccessNo.Checked)
                {
                    bIsAllowAccess = false;
                }

                if (rdAllowSignatoryYes.Checked)
                {
                    bIsAllowSignatory = true;
                }
                else if (rdAllowSignatoryNo.Checked)
                {
                    bIsAllowSignatory = false;
                }
                clsMaster                  = new clsMasters();
                clsMaster.MasterType       = this.MasterType;
                clsMaster.nMasterID        = Convert.ToInt64(lblTypeID.Text);
                clsMaster.nMasterMainID    = Convert.ToInt64(cmbAssetMainType.SelectedValue);
                clsMaster.sMasterName      = txtMainTypeName.Text.Trim();
                clsMaster.sMasterCode      = txtMasterCode.Text.Trim();
                clsMaster.IsAllowAccess    = bIsAllowAccess;
                clsMaster.IsAllowSignatory = bIsAllowSignatory;
                Int64 nResult = clsMaster.InsertUpdateMaster();
                if (nResult == -1)
                {
                    MessageBox.Show("Error while saving " + lblFormHeader.Text + ".", sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (nResult == 2)
                {
                    MessageBox.Show(lblFormHeader.Text + " is already exists.", sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show(lblFormHeader.Text + " is saved successfully.", sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearForm();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString(), clsGlobal._sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                if (clsMaster != null)
                {
                    clsMaster = null;
                }
            }
        }