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

                    lblKitAssetID.Text    = Convert.ToString(row[1]);
                    lblKitID.Text         = Convert.ToString(row[2]);
                    lblAssetID.Text       = Convert.ToString(row[3]);
                    lblAssetCodeID.Text   = Convert.ToString(row[4]);
                    lblAssetCodeName.Text = Convert.ToString(row[7]);
                    DataTable dtAssetList = (DataTable)cmbAssetList.DataSource;
                    DataRow   drAsset     = dtAssetList.NewRow();
                    drAsset["nAssetCodeID"]   = lblAssetCodeID.Text;
                    drAsset["sAssetCodeName"] = Convert.ToString(row[7]);
                    dtAssetList.Rows.InsertAt(drAsset, 0);

                    cmbAssetList.DataSource    = dtAssetList;
                    cmbAssetList.DisplayMember = "sAssetCodeName";
                    cmbAssetList.ValueMember   = "nAssetCodeID";
                    cmbAssetList.SelectedIndex = 0;
                    btnAddAsset.Text           = "Edit";
                }
                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 (Convert.ToInt64(lblKitID.Text) > 0)
                    {
                        Int64    nKitAssetID = Convert.ToInt64(row["nKitAssetID"]);
                        KitAsset oKitAsset   = new KitAsset();
                        oKitAsset.nKitAssetID = nKitAssetID;
                        if (oKitAsset.DeleteKitAsset() > 0)
                        {
                            MessageBox.Show("Asset code deleted successfully.", clsGlobal.MessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Asset code not deleted.", clsGlobal.MessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        FillAssetCode(Convert.ToInt64(lblKitID.Text));

                        if (oKitAsset != null)
                        {
                            oKitAsset.Dispose();
                            oKitAsset = null;
                        }
                    }
                    else
                    {
                        Int64     nAssetCodeID = Convert.ToInt64(row["nAssetCodeID"]);
                        DataRow[] drDelete     = dtAssetCode.Select("nAssetCodeID=" + Convert.ToInt64(nAssetCodeID));
                        foreach (DataRow dr in drDelete)
                        {
                            dr.Delete();
                        }
                        dtAssetCode.AcceptChanges();
                        int nRow = 0;
                        foreach (DataRow dr in dtAssetCode.Rows)
                        {
                            nRow++;
                            dr["RowNo"] = nRow;
                        }
                        //gvAssetList.GridControl.DataSource = dtAssetCode;
                        //gvAssetList.RefreshData();
                    }
                    gvAssetList.GridControl.DataSource = dtAssetCode;
                    gvAssetList.RefreshData();
                    FillAllAsset();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex, clsGlobal.MessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
0
        private void btnAddAsset_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateAssetCode())
                {
                    int    num    = 0;
                    string sValue = string.Empty;
                    num = dtAssetCode.Rows.Count;
                    num++;
                    sValue = num.ToString();
                    if (num < 1000)
                    {
                        sValue = num.ToString("000");
                    }
                    if (Convert.ToInt64(lblKitID.Text) > 0)
                    {
                        KitAsset oKitAsset = null;
                        if (btnAddAsset.Text.ToLower() == "add")
                        {
                            string[] sKitAssetName = cmbAssetList.Text.Trim().Split('-');
                            oKitAsset                    = new KitAsset();
                            oKitAsset.nAssetID           = 0;
                            oKitAsset.nAssetCodeID       = Convert.ToInt64(cmbAssetList.SelectedValue);
                            oKitAsset.nKitAssetID        = 0;
                            oKitAsset.nKitID             = Convert.ToInt64(lblKitID.Text);
                            oKitAsset.sAssetName         = Convert.ToString(sKitAssetName[0]);
                            oKitAsset.sUniqueCode        = Convert.ToString(sKitAssetName[1]);
                            oKitAsset.sAssetNameWithCode = Convert.ToString(cmbAssetList.Text);
                        }
                        else if (btnAddAsset.Text.ToLower() == "edit")
                        {
                            string[] sKitAssetName = cmbAssetList.Text.Trim().Split('-');
                            oKitAsset                    = new KitAsset();
                            oKitAsset.nAssetID           = Convert.ToInt64(lblAssetID.Text);
                            oKitAsset.nAssetCodeID       = Convert.ToInt64(lblAssetCodeID.Text);
                            oKitAsset.nKitAssetID        = Convert.ToInt64(lblKitAssetID.Text);
                            oKitAsset.nKitID             = Convert.ToInt64(lblKitID.Text);
                            oKitAsset.sAssetName         = Convert.ToString(sKitAssetName[0]);
                            oKitAsset.sUniqueCode        = Convert.ToString(sKitAssetName[1]);
                            oKitAsset.sAssetNameWithCode = Convert.ToString(lblAssetCodeName.Text);
                        }
                        Int64 nStatus = oKitAsset.UpdateAssetCode();

                        if (nStatus > 0)
                        {
                            FillAssetCode(oKitAsset.nKitID);
                        }
                    }
                    else
                    {
                        string[] sKitAssetName = cmbAssetList.Text.Trim().Split('-');

                        DataRow drKit = dtAssetCode.NewRow();
                        drKit["RowNo"]             = num;
                        drKit["nKitAssetID"]       = 0;
                        drKit["nKitID"]            = 0;
                        drKit["nAssetID"]          = 0;
                        drKit["nAssetCodeID"]      = Convert.ToInt64(cmbAssetList.SelectedValue);
                        drKit["sUniqueCode"]       = sKitAssetName[1];
                        drKit["sAssetName"]        = sKitAssetName[0];
                        drKit["assetNameWithCode"] = cmbAssetList.Text.Trim();

                        dtAssetCode.Rows.Add(drKit);
                        gvAssetList.GridControl.DataSource = dtAssetCode;
                        gvAssetList.Columns[1].Visible     = false;
                        gvAssetList.Columns[2].Visible     = false;
                        gvAssetList.Columns[5].Visible     = false;
                    }
                    ClearKitDetails();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error asset code: " + ex.ToString(), clsGlobal.MessageboxCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }