Beispiel #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtName.Text) || string.IsNullOrWhiteSpace(txtType.Text) || string.IsNullOrWhiteSpace(cmbUnit.Text))
            {
                ClsCommon.ShowErrorToolTip(txtName, "Please Enter The ProductionMaterial Name");
            }
            else
            {
                var model = new ProductionMaterialModel
                {
                    ProductionMaterialId = _productionMaterialId,
                    MaterialName         = txtName.Text,
                    MaterialType         = txtType.Text,
                    Description          = txtDesc.Text,
                    UnitOfMeasurementId  = (int)cmbUnit.SelectedValue
                };

                if (_isNewMode)
                {
                    _productionMaterialId = _productionMaterialService.Save(model).ProductionMaterialId;
                    if (_productionMaterialId <= 0)
                    {
                        return;
                    }
                    MessageBox.Show(@"Data Saved Successfully", @"Save", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    var frm = (FrmProductionMaterial)_frmForm;
                    frm.grdData.Rows.Add(_productionMaterialId, model.MaterialName, model.UnitOfMeasurementId, cmbUnit.Text, model.MaterialType, model.Description);
                    frm.grdData.Rows[frm.grdData.Rows.Count - 1].IsSelected = true;
                    txtName.Focus();
                    txtName.Text = "";
                    Notify();
                }
                else
                {
                    var success = _productionMaterialService.Update(model).ProductionMaterialId;
                    if (success <= 0)
                    {
                        return;
                    }
                    MessageBox.Show(@"Data Updated Successfully", @"Update", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    var frm = (FrmProductionMaterial)_frmForm;
                    frm.grdData.CurrentRow.Cells["MaterialName"].Value        = model.MaterialName;
                    frm.grdData.CurrentRow.Cells["MaterialType"].Value        = model.MaterialType;
                    frm.grdData.CurrentRow.Cells["UnitOfMeasurementId"].Value = model.UnitOfMeasurementId;
                    frm.grdData.CurrentRow.Cells["UnitName"].Value            = cmbUnit.Text;
                    frm.grdData.CurrentRow.Cells["Description"].Value         = model.Description;
                    Close();
                    Notify();
                }
            }
        }
Beispiel #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(lblID.Text) <= 0)
            {
                return;
            }
            var model = new ProductionMaterialModel()
            {
                ProductionMaterialId = Convert.ToInt32(lblID.Text),
                MaterialName         = lblName.Text,
                UnitOfMeasurementId  = _unitId,
                MaterialType         = lblType.Text,
                Description          = lblDesc.Text
            };

            var frm = new FrmProductionMaterialEntry(model, this);

            frm.ShowDialog(this);
        }
Beispiel #3
0
 public FrmProductionMaterialEntry(ProductionMaterialModel model, Form frmForm)
 {
     InitializeComponent();
     _unitService = new UnitService();
     _frmForm     = frmForm;
     _productionMaterialService = new ProductionMaterialService();
     LoadUnits();
     if (model != null)
     {
         _isNewMode            = false;
         _productionMaterialId = model.ProductionMaterialId;
         txtName.Text          = model.MaterialName;
         txtType.Text          = model.MaterialType;
         txtDesc.Text          = model.Description;
         cmbUnit.SelectedValue = model.UnitOfMeasurementId;
         btnAdd.Text           = @"Update";
     }
     else
     {
         _isNewMode  = true;
         btnAdd.Text = @"Save";
     }
 }