コード例 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (txtCode.Text != "")
            {
                DLUnit objDLMaterial = new DLUnit();

                int ID = objDLMaterial.FetchIDbyCode(txtCode.Text);

                if (ID > 0)
                {
                    if (objDLMaterial.DeleteByID(ID) > 0)
                    {
                        MessageBox.Show("Record Deleted");
                        ClearControls();
                    }
                    else
                    {
                        MessageBox.Show("Record not Deleted");
                    }
                }
                else
                {
                    MessageBox.Show("Invalid Code");
                }
            }
            else
            {
                MessageBox.Show("Invalid Code");
            }
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            ELUnit objELUnit = new ELUnit();
            DLUnit objDLUnit = new DLUnit();
            int newID = 0;

            if (lblUnitID.Text.Length > 0)
            {
                objELUnit.ID = Convert.ToInt32(lblUnitID.Text);
            }
            else
            {
                newID = Common.GetNewID(tableName);
                objELUnit.ID = newID;
            }

            objELUnit.Code = txtCode.Text;
            objELUnit.Name = txtName.Text;
            objELUnit.Creator = 0;
            objELUnit.Created = DateTime.Now;
            objELUnit.IsActive = false;

            if (chkIsActive.Checked) objELUnit.IsActive = true;

            if (Validations())
            {
                if (objDLUnit.Add(objELUnit) > 0)
                {
                    MessageBox.Show("Record Inserted");
                    // ClearControls();
                }
                else
                {
                    MessageBox.Show("Record not Inserted");
                }
            }
        }
コード例 #3
0
        private void gvUnit_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex > 0)
            {

                string strCode = gvUnit.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                string unitID = gvUnit.Rows[e.RowIndex].Cells[0].Value.ToString();

                ELUnit objELUnit = new ELUnit();
                DLUnit objDLUnit = new DLUnit();

                objELUnit = objDLUnit.FetchUnitsByID(Convert.ToInt32(unitID));

                if (objELUnit != null)
                {
                    lblUnitID.Text = objELUnit.ID.ToString();
                    txtCode.Text = objELUnit.Code;
                    txtName.Text = objELUnit.Name;
                    chkIsActive.Checked = Convert.ToBoolean(objELUnit.IsActive);
                }
            }
            gvUnit.Visible = false;
        }
コード例 #4
0
        private void btnView_Click(object sender, EventArgs e)
        {
            gvUnit.Visible = true;
            ClearControls();
            DLUnit objDLUnit = new DLUnit();

            gvUnit.DataSource = objDLUnit.FetchUnits();

            if (gvUnit.Rows.Count > 0)
            {
                for (int i = 0; i <= gvUnit.Rows.Count - 1; i++)
                {
                    gvUnit.Columns[0].Visible = false;
                }
            }
        }