private void gvKitList_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventArgs e)
        {
            try
            {
                if (e.Column.Caption == "Edit")
                {
                    Int64 nKitID = 0;
                    var   row    = gvKitList.GetFocusedDataRow();

                    nKitID = Convert.ToInt64(row[1]);
                    frmAddKit frmKit = new frmAddKit(nKitID);
                    frmKit.ShowDialog();
                    FillKitList();
                }
                if (e.Column.Caption == "Delete")
                {
                    var row = gvKitList.GetFocusedDataRow();
                    int n   = Convert.ToString(gvKitList.GetRowCellValue(e.RowHandle, "IsUsed")) == "" || Convert.ToString(gvKitList.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;
                    }
                    KitMaster oKitMaster = new KitMaster();
                    oKitMaster.nKitID = Convert.ToInt64(row[1]);
                    if (oKitMaster.DeleteKit() > 0)
                    {
                        MessageBox.Show("Kit details deleted successfully.", clsGlobal._sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    if (oKitMaster != null)
                    {
                        oKitMaster.Dispose();
                        oKitMaster = null;
                    }
                    //clsMasters oclsMaster = new clsMasters();
                    //oclsMaster.nMasterID = Convert.ToInt64(row[1]);
                    //oclsMaster.MasterType = this.MasterType;
                    //oclsMaster.DeleteMaster();
                    FillKitList();
                }
                if (e.Column.Caption == "Show Asset")
                {
                    Int64 nKitID = 0;
                    var   row    = gvKitList.GetFocusedDataRow();

                    nKitID = Convert.ToInt64(row[1]);
                    frmMainKitAssetList oFrmAssetCodeList = new frmMainKitAssetList(nKitID);
                    oFrmAssetCodeList.ShowDialog();
                    FillKitList();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex, clsGlobal.MessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void FillKitInformation(long nKitID)
        {
            KitMaster oKitMaster = null;
            DataSet   ds         = null;

            try
            {
                oKitMaster = new KitMaster();
                ds         = oKitMaster.GetKitDetails(nKitID);
                if (ds != null && ds.Tables.Count > 0)
                {
                    DataTable dtKitDetails      = ds.Tables[0];
                    DataTable dtKitAssetDetails = ds.Tables[1];

                    if (dtKitDetails != null && dtKitDetails.Rows.Count > 0)
                    {
                        lblKitID.Text          = Convert.ToString(dtKitDetails.Rows[0]["nKitID"]);
                        txtKitName.Text        = Convert.ToString(dtKitDetails.Rows[0]["sKitName"]);
                        txtKitCode.Text        = Convert.ToString(dtKitDetails.Rows[0]["sKitCode"]);
                        txtAbbrivation.Text    = Convert.ToString(dtKitDetails.Rows[0]["sKitAbbrivation"]);
                        txtKitDescription.Text = Convert.ToString(dtKitDetails.Rows[0]["sKitDescription"]);
                        byte[] barcodeImage = (byte[])dtKitDetails.Rows[0]["Barcode"];

                        if (barcodeImage.Length > 0)
                        {
                            barcodeImage = (byte[])dtKitDetails.Rows[0]["Barcode"];
                            MemoryStream msHeaderImage = new MemoryStream(barcodeImage);
                            picBarcodeImage.Image = Image.FromStream(msHeaderImage);
                        }
                    }
                    if (dtKitAssetDetails != null)
                    {
                        gvAssetList.GridControl.DataSource = dtKitAssetDetails;
                        gvAssetList.Columns[1].Visible     = false;
                        gvAssetList.Columns[2].Visible     = false;
                        gvAssetList.Columns[5].Visible     = false;
                    }
                    btnUpdateKit.Visible = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString(), clsGlobal._sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void FillAssetKitDetails(long nKitID)
        {
            KitMaster oKitMaster  = null;
            DataTable dtAssetCode = null;

            try
            {
                oKitMaster  = new KitMaster();
                dtAssetCode = oKitMaster.GetKitAssetList(nKitID);
                if (dtAssetCode != null)
                {
                    gvKitAssetList.GridControl.DataSource = dtAssetCode;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString(), clsGlobal._sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 4
0
        private void FillAssetCode(Int64 nKitID = 0)
        {
            KitMaster oKit = null;

            try
            {
                oKit        = new KitMaster();
                dtAssetCode = oKit.GetKitAssetAssociation(nKitID);
                if (dtAssetCode != null)
                {
                    gvAssetList.GridControl.DataSource = dtAssetCode;
                    gvAssetList.Columns[1].Visible     = false;
                    gvAssetList.Columns[2].Visible     = false;
                    gvAssetList.Columns[5].Visible     = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString(), clsGlobal._sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private void FillKitList()
        {
            KitMaster oKitMaster = null;
            DataTable dt         = null;

            try
            {
                oKitMaster = new KitMaster();
                dt         = oKitMaster.GetKitList(0);
                if (dt != null)
                {
                    gvKitList.GridControl.DataSource = dt;
                    gvKitList.Columns[1].Visible     = false;
                    gvKitList.Columns[8].Visible     = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString(), clsGlobal._sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 6
0
        private void SaveKitDetils(bool bIsSaveKit_Asset = true)
        {
            KitMaster oKitMaster = null;

            try
            {
                oKitMaster                 = new KitMaster();
                oKitMaster.nKitID          = Convert.ToInt64(lblKitID.Text);
                oKitMaster.sKitName        = txtKitName.Text.Trim();
                oKitMaster.sKitCode        = txtKitCode.Text.Trim();
                oKitMaster.sKitAbbrivation = txtAbbrivation.Text.Trim();
                oKitMaster.sKitDescription = txtKitDescription.Text.Trim();
                byte[] BarcodeImage = new byte[] { };
                if (picBarcodeImage != null)
                {
                    if (picBarcodeImage.Image != null)
                    {
                        using (MemoryStream ms = new MemoryStream())
                        {
                            picBarcodeImage.Image.Save(ms, ImageFormat.Jpeg);
                            BarcodeImage = new byte[ms.Length];
                            ms.Position  = 0;
                            ms.Read(BarcodeImage, 0, BarcodeImage.Length);
                        }
                    }
                }
                oKitMaster.kitBarcode = BarcodeImage;
                List <KitAsset> lstKitAsset = new List <KitAsset>();
                foreach (DataRow dr in dtAssetCode.Rows)
                {
                    using (KitAsset oKitAsset = new KitAsset())
                    {
                        oKitAsset.nKitID             = Convert.ToInt64(dr["nKitID"]);
                        oKitAsset.nKitAssetID        = Convert.ToInt64(dr["nKitAssetID"]);
                        oKitAsset.nAssetID           = Convert.ToInt64(dr["nAssetID"]);
                        oKitAsset.nAssetCodeID       = Convert.ToInt64(dr["nAssetCodeID"]);
                        oKitAsset.sAssetName         = Convert.ToString(dr["sAssetName"]);
                        oKitAsset.sUniqueCode        = Convert.ToString(dr["sUniqueCode"]);
                        oKitAsset.sAssetNameWithCode = Convert.ToString(dr["assetNameWithCode"]);
                        lstKitAsset.Add(oKitAsset);
                    }
                }
                oKitMaster.lstKitDetails = lstKitAsset;

                Int64 nKitID = oKitMaster.InsertUpdateKitDetails(bIsSaveKit_Asset);
                if (nKitID == 0)
                {
                    MessageBox.Show("Kit details not saved.", clsGlobal.MessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (nKitID == 2)
                {
                    MessageBox.Show("Kit code already present. Please change asset code.", clsGlobal.MessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Kit details saved successfuly", clsGlobal.MessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                    ClearKit();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.ToString(), clsGlobal._sMessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }