Exemple #1
0
 private void CustomerView_Load(object sender, EventArgs e)
 {
     AniHelper.FillCombo(cmbSlot, db.Slots.Where(x => x.OccupaidStatus == false).ToList().Cast <object>().ToList());
     AniHelper.FillCombo(cmbStaff, db.Staffs.Where(x => x.Name != "Admin").ToList().Cast <object>().ToList());
     BindDGV(db.Customers.ToList());
     this.ActiveControl = txtPanNo;
 }
Exemple #2
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     AniHelper.ClearMethod(this);
     iStaffId = null;
     dgvStaff.AutoGenerateColumns = false;
     dgvStaff.DataSource          = db.Staffs.ToList();
     txtName.Focus();
 }
Exemple #3
0
 private void tabMdi_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (tabMdi.SelectedIndex == 0)
     {
         AniHelper.FillCombo(cmbSlot, db.Slots.Where(x => x.OccupaidStatus == false).ToList().Cast <object>().ToList());
         AniHelper.FillCombo(cmbStaff, db.Staffs.Where(x => x.Name != "Admin").ToList().Cast <object>().ToList());
         txtSearch.Focus();
     }
 }
Exemple #4
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     iCustomerId = null;
     AniHelper.ClearMethod(this);
     AniHelper.FillCombo(cmbSlot, db.Slots.Where(x => x.OccupaidStatus == false).ToList().Cast <object>().ToList());
     AniHelper.FillCombo(cmbStaff, db.Staffs.Where(x => x.Name != "Admin").ToList().Cast <object>().ToList());
     btnInOrOut.Visible = false;
     txtPanNo.Focus();
 }
Exemple #5
0
        public static bool UpdateMethod_SP(object entity, string sStoredProceedure, string Connection)
        {
            bool result = false;
            int  numRes = 0;

            using (SqlConnection con = new SqlConnection(Connection))
            {
                using (SqlCommand cmd = new SqlCommand(sStoredProceedure, con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    try
                    {
                        foreach (var item in entity.GetType().GetProperties())
                        {
                            if (item.GetValue(entity, null) != null)
                            {
                                if (item.PropertyType.Name == "Nullable`1" && item.GetValue(entity, null).ToString() == "0")
                                {
                                    continue;
                                }
                                if (item.PropertyType.Name == "Byte[]")
                                {
                                    cmd.Parameters.AddWithValue(item.Name, (byte[])(item.GetValue(entity, null)));
                                }
                                else if (item.PropertyType.Name == "DateTime")
                                {
                                    cmd.Parameters.AddWithValue("@" + item.Name, AniHelper.GetDate((DateTime)(item.GetValue(entity, null))));
                                }
                                else
                                {
                                    cmd.Parameters.AddWithValue(item.Name, item.GetValue(entity, null).ToString());
                                }
                            }
                        }
                        con.Open();
                        numRes = cmd.ExecuteNonQuery();
                    }
                    catch (Exception)
                    {
                        result = false;
                        throw;
                    }
                }
            }
            if (numRes > 0)
            {
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }
Exemple #6
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     AniHelper.ClearMethod(this);
     slots                     = new List <Slot>();
     oldSlots                  = new List <Slot>();
     dgSlot.DataSource         = null;
     dgBox.AutoGenerateColumns = false;
     dgBox.DataSource          = db.Boxes.ToList();
     iBoxId                    = null;
     txtName.Enabled           = true;
     txtName.Focus();
 }
Exemple #7
0
 private void SlotView_Load(object sender, EventArgs e)
 {
     AniHelper.FillCombo(cmbStaff, db.Staffs.Where(x => x.Name != "Admin").Cast <object>().ToList());
     if (entTransactions != null)
     {
         slot                   = db.Slots.FirstOrDefault(x => x.Id == entTransactions.FK_Slot);
         lblBoxName.Text        = db.Boxes.FirstOrDefault(x => x.Id == slot.FK_BoxId).Name;
         lblSlotName.Text       = slot.Name;
         lblCustomer.Text       = db.Customers.FirstOrDefault(x => x.Id == entTransactions.FK_Customer).Name;
         cmbStaff.SelectedValue = entTransactions.FK_Staff;
         cmbStaff.Focus();
     }
 }
Exemple #8
0
 private void btnClear_Click(object sender, EventArgs e)
 {
     iCustomerId          = null;
     txtSearch.Text       = string.Empty;
     customers            = db.Customers;
     customer             = new Customer();
     dgDetails.DataSource = customers;
     AniHelper.PanelClearMethod(pnlCustomer);
     AniHelper.FillCombo(cmbSlot, db.Slots.Where(x => x.OccupaidStatus == false).ToList().Cast <object>().ToList());
     AniHelper.FillCombo(cmbStaff, db.Staffs.Where(x => x.Name != "Admin").ToList().Cast <object>().ToList());
     btnInOrOut.Visible = false;
     txtSearch.Focus();
 }
Exemple #9
0
 private void Main_Load(object sender, EventArgs e)
 {
     this.WindowState = FormWindowState.Maximized;
     customers        = new List <Customer>();
     AniHelper.FillCombo(cmbSlot, db.Slots.Where(x => x.OccupaidStatus == false).ToList().Cast <object>().ToList());
     AniHelper.FillCombo(cmbStaff, db.Staffs.Where(x => x.Name != "Admin").ToList().Cast <object>().ToList());
     lblUser.Text = db.Staffs.FirstOrDefault(x => x.Id == User.iUserId).Name;
     if (db.Boxes.Count == 0)
     {
         btnBox_Click(null, null);
     }
     customers = db.Customers;
     dgDetails.AutoGenerateColumns = false;
     dgDetails.DataSource          = customers;
 }
Exemple #10
0
 private void CustomerLoadMethod()
 {
     if (customer != null)
     {
         AniHelper.FillCombo(cmbSlot, db.Slots.Cast <object>().ToList());
         txtName.Text              = customer.Name;
         txtPassword.Text          = customer.Password;
         txtPanNo.Text             = customer.PanNumber;
         txtCareof.Text            = customer.Careof;
         txtCompany.Text           = customer.Company;
         iCustomerId               = customer.Id;
         cmbStaff.SelectedValue    = customer.Fk_StaffId;
         cmbSlot.SelectedValue     = customer.Fk_SlotId;
         cmbExpaired.SelectedIndex = customer.isExpaired ? 1 : 0;
         btnInOrOut.Visible        = true;
     }
 }
Exemple #11
0
 private void dgvStaff_CellContentClick(object sender, DataGridViewCellEventArgs e)
 {
     if (e.RowIndex >= 0)
     {
         Customer customer = db.Customers.FirstOrDefault(x => x.Name == dgvStaff.CurrentRow.Cells[0].Value.ToString());
         if (customer != null)
         {
             AniHelper.FillCombo(cmbSlot, db.Slots.Cast <object>().ToList());
             txtName.Text              = customer.Name;
             txtPassword.Text          = customer.Password;
             txtPanNo.Text             = customer.PanNumber;
             txtCareof.Text            = customer.Careof;
             txtCompany.Text           = customer.Company;
             iCustomerId               = customer.Id;
             cmbStaff.SelectedValue    = customer.Fk_StaffId;
             cmbSlot.SelectedValue     = customer.Fk_SlotId;
             cmbExpaired.SelectedIndex = customer.isExpaired ? 1 : 0;
             btnInOrOut.Visible        = true;
         }
     }
 }
Exemple #12
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            dgDetails.DataSource  = null;
            dgvReports.DataSource = null;
            AniHelper.PanelClearMethod(pnlCustomer);
            if (txtSearch.Text == string.Empty)
            {
                return;
            }
            List <Customer> exCustomers = new List <Customer>();

            exCustomers = ORMForSDF.GetList_SP <Customer>("spGetMainCusomers", new { sText = txtSearch.Text }, Properties.Settings.Default.Connection);

            if (exCustomers.Count > 0)
            {
                dgDetails.AutoGenerateColumns = false;
                dgDetails.DataSource          = exCustomers;
                customer = exCustomers.FirstOrDefault();
                CustomerLoadMethod();
                GenerateReports(txtSearch.Text);
            }
        }
Exemple #13
0
        public static bool UpdateToDatabaseObj(object data, string table, string column, int iValue, string Connection)
        {
            try
            {
                List <KeyValuePair <string, string> > values = new List <KeyValuePair <string, string> >();
                using (SqlConnection con = new SqlConnection(Connection))
                {
                    try
                    {
                        foreach (var item in data.GetType().GetProperties())
                        {
                            if (item.GetValue(data, null) != null && item.Name != column)
                            {
                                if (item.PropertyType.Name == "Nullable`1" && item.GetValue(data, null).ToString() == "0")
                                {
                                    continue;
                                }
                                values.Add(new KeyValuePair <string, string>(item.Name, "@" + item.Name));
                            }
                        }
                        string Query = getUpdateCommand(table, values, column, "@" + column);
                        using (SqlCommand cmd = new SqlCommand(Query, con))
                        {
                            cmd.Parameters.Clear();
                            cmd.Parameters.AddWithValue("@" + column, iValue);
                            foreach (var item in data.GetType().GetProperties())
                            {
                                if (item.GetValue(data, null) != null && item.Name != column)
                                {
                                    if (item.PropertyType.Name == "Nullable`1" && item.GetValue(data, null).ToString() == "0")
                                    {
                                        continue;
                                    }
                                    if (item.PropertyType.Name == "Byte[]")
                                    {
                                        cmd.Parameters.AddWithValue("@" + item.Name, (byte[])(item.GetValue(data, null)));
                                    }
                                    else if (item.PropertyType.Name == "DateTime")
                                    {
                                        cmd.Parameters.AddWithValue("@" + item.Name, AniHelper.GetDate((DateTime)(item.GetValue(data, null))));
                                    }
                                    else
                                    {
                                        cmd.Parameters.AddWithValue("@" + item.Name, item.GetValue(data, null).ToString());
                                    }
                                }
                            }
                            con.Open();
                            cmd.ExecuteNonQuery();
                        }
                    }
                    catch (Exception ex)
                    {
                        Messages.ErrorMessage(ex.Message);
                        return(false);

                        throw;
                    }
                }
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }