Exemple #1
0
        private void LoadSparePartsType()
        {
            SparePartsTypeBL expenseBL = new SparePartsTypeBL();

            dgSparePartsType.DataSource = expenseBL.GetSparePartsTypes().Select(o => new
                                                                                { SparePartsTypeID = o.SparePartsTypeID, Description = o.Description }).ToList();

            if (dgSparePartsType.Rows.Count == 0)
            {
                btnEdit.Enabled   = false;
                btnDelete.Enabled = false;
            }
            else
            {
                btnEdit.Enabled   = true;
                btnDelete.Enabled = true;
            }
        }
Exemple #2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (validate())
            {
                if (btntext == "ADD")
                {
                    SparePartsTypeDTO spDTO = new SparePartsTypeDTO();
                    spDTO.Description  = txtDescription.Text;
                    spDTO.CreatedBy    = GlobalSetup.Userid;
                    spDTO.CreatedDate  = DateTime.Now;
                    spDTO.ModifiedDate = DateTime.Now;
                    SparePartsTypeBL expen = new SparePartsTypeBL();
                    var result             = expen.AddSpareParts(spDTO);
                    LoadSparePartsType();

                    if (result)
                    {
                        MyMessageBox.ShowBox("SpareParts Type is Saved", "SpareParts");
                    }
                    else
                    {
                        MyMessageBox.ShowBox("SpareParts Save is failed !!!");
                    }
                }
                else
                {
                    SparePartsTypeDTO expenseDTO = new SparePartsTypeDTO();
                    expenseDTO.Description      = txtDescription.Text;
                    expenseDTO.SparePartsTypeID = Convert.ToInt32(dgSparePartsType.CurrentRow.Cells["SparePartsTypeID"].Value);
                    expenseDTO.ModifiedDate     = DateTime.Now;
                    expenseDTO.ModifiedBy       = GlobalSetup.Userid;
                    SparePartsTypeBL exp = new SparePartsTypeBL();
                    var result           = exp.UpdateSpareParts(expenseDTO);
                    btntext = "ADD";
                }
                clear();
                LoadSparePartsType();
            }
            else
            {
                MyMessageBox.ShowBox("Description cannot be Empty !!!");
            }
        }
Exemple #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            string id = MyMessageBoxYesorNo.ShowBox("Are you sure to Delete??");

            if (id == "1")
            {
                var expenseID          = dgSparePartsType.CurrentRow.Cells["SparePartsTypeID"].Value.ToString();
                SparePartsTypeBL expen = new SparePartsTypeBL();
                var result             = expen.DeleteSpareParts(Convert.ToInt32(expenseID));
                if (result)
                {
                    MyMessageBox.ShowBox("Expenses Deleted");
                }
                else
                {
                    MyMessageBox.ShowBox("Failed");
                }
                clear();
                LoadSparePartsType();
            }
        }