Ejemplo n.º 1
0
        private void gvAssetList_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            try
            {
                if (e.Column.Caption == "Edit")
                {
                    Int64 nAssetID = 0;
                    var   row      = gvAssetList.GetFocusedDataRow();

                    nAssetID = Convert.ToInt64(row[1]);
                    frmAddAsset frmAsset = new frmAddAsset(nAssetID);
                    frmAsset.ShowDialog();
                    FillAssetList();
                }
                if (e.Column.Caption == "Delete")
                {
                    var row = gvAssetList.GetFocusedDataRow();
                    int n   = Convert.ToString(gvAssetList.GetRowCellValue(e.RowHandle, "IsUsed")) == "" || Convert.ToString(gvAssetList.GetRowCellValue(e.RowHandle, "IsUsed")) == "0" ? 0 : 1;

                    if (n == 1)
                    {
                        return;
                    }
                    if (MessageBox.Show("Do you want to delete?", clsGlobal._sMessageboxCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    AssetMaster oAssetMaster = new AssetMaster();
                    oAssetMaster.nAssetID = Convert.ToInt64(row[1]);
                    if (oAssetMaster.DeleteAsset() > 0)
                    {
                        MessageBox.Show("Asset details deleted successfully.", clsGlobal._sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    if (oAssetMaster != null)
                    {
                        oAssetMaster.Dispose();
                        oAssetMaster = null;
                    }
                    //clsMasters oclsMaster = new clsMasters();
                    //oclsMaster.nMasterID = Convert.ToInt64(row[1]);
                    //oclsMaster.MasterType = this.MasterType;
                    //oclsMaster.DeleteMaster();
                    FillAssetList();
                }
                if (e.Column.Caption == "Show Asset")
                {
                    Int64 nAssetID = 0;
                    var   row      = gvAssetList.GetFocusedDataRow();

                    nAssetID = Convert.ToInt64(row[1]);
                    frmMainAssetCodeList oFrmAssetCodeList = new frmMainAssetCodeList(nAssetID);
                    oFrmAssetCodeList.ShowDialog();
                    FillAssetList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex, clsGlobal.MessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        private void LoadMasterData()
        {
            AssetMaster oAssetMaster = null;
            DataSet     dsMaster     = null;

            try
            {
                oAssetMaster = new AssetMaster();
                dsMaster     = oAssetMaster.GetAllMasterData(0);

                if (dsMaster != null && dsMaster.Tables.Count > 0)
                {
                    cmbAssetTypeName.DataSource    = dsMaster.Tables[0];
                    cmbAssetTypeName.DisplayMember = "sAssetType";
                    cmbAssetTypeName.ValueMember   = "nAssetMainTypeID";

                    cmbAssetmaterialType.DataSource    = dsMaster.Tables[1];
                    cmbAssetmaterialType.DisplayMember = "sAssetMaterialName";
                    cmbAssetmaterialType.ValueMember   = "nAssetMaterialID";

                    cmbAssetType.DataSource    = dsMaster.Tables[2];
                    cmbAssetType.DisplayMember = "sAssetTypeName";
                    cmbAssetType.ValueMember   = "nAssetTypeID";

                    cmbAssetType1.DataSource    = dsMaster.Tables[3];
                    cmbAssetType1.DisplayMember = "sAssetTypeOneName";
                    cmbAssetType1.ValueMember   = "nAssetTypeOneID";

                    cmbAssetShelfLifeUnit.DataSource    = dsMaster.Tables[4];
                    cmbAssetShelfLifeUnit.DisplayMember = "sAssetShelfLifeUnit";
                    cmbAssetShelfLifeUnit.ValueMember   = "nAssetShelfLifeUnit";
                }
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (oAssetMaster != null)
                {
                    oAssetMaster.Dispose();
                    oAssetMaster = null;
                }
            }
        }