Beispiel #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     slot.InStatus       = cmbInOrOut.SelectedIndex == 0 ? false : true;
     slot.OccupaidStatus = cmbOccupaid.SelectedIndex == 0 ? false : true;
     slot.FK_CustomerId  = entTransactions.FK_Customer;
     slot.FK_StaffId     = cmbStaff.SelectedValue.ToInt32();
     if (ORMForSDF.UpdateToDatabaseObj(slot, "Slot", "Id", slot.Id.toInt32(), Properties.Settings.Default.Connection))
     {
         string status = string.Empty;
         if (cmbOccupaid.SelectedIndex == 0)
         {
             status = "Alotment Removed";
         }
         else
         {
             if (cmbInOrOut.SelectedIndex == 0)
             {
                 status = "Outed";
             }
             else
             {
                 status = "In";
             }
         }
         entTransactions.FK_Staff = cmbStaff.SelectedValue.ToInt32();
         entTransactions.Date     = DateTime.Now;
         entTransactions.Status   = status;
         if (ORMForSDF.InsertToDatabaseObj(entTransactions, "Transactions", Properties.Settings.Default.Connection))
         {
             this.DialogResult = System.Windows.Forms.DialogResult.OK; this.Close();
         }
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Beispiel #2
0
        private void txtSearch_TextChanged(object sender, EventArgs e)
        {
            exCustomerDataGridView.DataSource = null;
            if (txtSearch.Text == string.Empty)
            {
                return;
            }
            List <ExCustomer> exCustomers = new List <ExCustomer>();
            DataTable         dt          = ORMForSDF.GetDataTableWithIdParameter_SP("spGetCustomerReport", new { sText = txtSearch.Text }, Properties.Settings.Default.Connection);
            int iCount = 1;

            foreach (DataRow item in dt.Rows)
            {
                ExCustomer exCustomer = new ExCustomer();
                exCustomer.SL         = iCount;
                exCustomer.Id         = item[0].ToInt32();
                exCustomer.Name       = item[1].ToString();
                exCustomer.PanNumber  = item[2].ToString();
                exCustomer.Company    = item[3].ToString();
                exCustomer.Careof     = item[4].ToString();
                exCustomer.isExpaired = item[5].ToString().ToBool();
                exCustomer.Staffname  = item[6].ToString();
                exCustomer.Expaired   = exCustomer.isExpaired ? "Expaired" : "Active";
                iCount++;
                exCustomers.Add(exCustomer);
            }
            exCustomerDataGridView.AutoGenerateColumns = false;
            exCustomerDataGridView.DataSource          = exCustomers;
        }
Beispiel #3
0
        private void GenerateReports(int iValue)
        {
            List <ExTransactions> exTransactions = new List <ExTransactions>();

            exTransactions = ORMForSDF.GetList_SP <ExTransactions>("spGetTransactionForMainReport", new { Val = iValue }, Properties.Settings.Default.Connection);
            dgvReports.AutoGenerateColumns = false;
            dgvReports.DataSource          = exTransactions;
        }
Beispiel #4
0
        private void GenerateReports(string sText)
        {
            List <ExTransactions> exTransactions = new List <ExTransactions>();

            exTransactions = ORMForSDF.GetList_SP <ExTransactions>("spGetTransactionReport", new { sText = txtSearch.Text }, Properties.Settings.Default.Connection);
            dgvReports.AutoGenerateColumns = false;
            dgvReports.DataSource          = exTransactions;
        }
Beispiel #5
0
        private void txtPanNo_TextChanged(object sender, EventArgs e)
        {
            dgvReports.DataSource = null;
            List <ExTransactions> exTransactions = new List <ExTransactions>();

            exTransactions = ORMForSDF.GetList_SP <ExTransactions>("spGetTransactionReport", new { sText = txtSearch.Text }, Properties.Settings.Default.Connection);
            dgvReports.AutoGenerateColumns = false;
            dgvReports.DataSource          = exTransactions;
        }
Beispiel #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text == string.Empty || txtPanNo.Text == string.Empty)
            {
                Messages.WarningMessage(); return;
            }
            var customer = new Customer
            {
                Id         = iCustomerId,
                Name       = txtName.Text,
                PanNumber  = txtPanNo.Text,
                Company    = txtCompany.Text,
                Careof     = txtCareof.Text,
                Password   = txtPassword.Text,
                Fk_SlotId  = cmbSlot.SelectedValue.ToInt32(),
                Fk_StaffId = cmbStaff.SelectedValue.ToInt32(),
                isExpaired = cmbExpaired.SelectedIndex == 0 ? false : true
            };

            if (iCustomerId == null || !db.Customers.Any(x => x.Id == iCustomerId))
            {
                if (ORMForSDF.InsertToDatabaseObj(customer, "Customer", Properties.Settings.Default.Connection))
                {
                    customer = db.Customers.FirstOrDefault(x => x.Name == txtName.Text);
                    Slot slot = db.Slots.FirstOrDefault(x => x.Id == cmbSlot.SelectedValue.ToInt32());
                    slot.OccupaidStatus = true;
                    slot.InStatus       = true;
                    slot.FK_CustomerId  = customer.Id;
                    slot.FK_StaffId     = cmbStaff.SelectedValue.ToInt32();
                    ORMForSDF.UpdateToDatabaseObj(slot, "Slot", "Id", slot.Id.toInt32(), Properties.Settings.Default.Connection);
                    var transaction = new Transactions {
                        Id = null, FK_Customer = slot.FK_CustomerId, FK_Slot = slot.Id, FK_Staff = cmbStaff.SelectedValue.ToInt32(), Date = DateTime.Now.Date, Status = "Allotted", Remarks = ""
                    };
                    if (ORMForSDF.InsertToDatabaseObj(transaction, "Transactions", Properties.Settings.Default.Connection))
                    {
                        var trans = new Transactions {
                            Id = null, FK_Customer = slot.FK_CustomerId, FK_Slot = slot.Id, FK_Staff = cmbStaff.SelectedValue.ToInt32(), Date = DateTime.Now.Date, Status = "In", Remarks = ""
                        };
                        if (ORMForSDF.InsertToDatabaseObj(trans, "Transactions", Properties.Settings.Default.Connection))
                        {
                            Messages.SavedMessage(); btnClear_Click(null, null);
                        }
                    }
                }
            }
            else
            {
                if (ORMForSDF.UpdateToDatabaseObj(customer, "Customer", "Id", iCustomerId.toInt32(), Properties.Settings.Default.Connection))
                {
                    Messages.UpdateMessage(); btnClear_Click(null, null);
                }
            }
        }
Beispiel #7
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (Messages.DeleteConfirmationMessage() && iBoxId != null)
     {
         if (ORMForSDF.DeleteFromDatabase("Slot", "FK_BoxId", iBoxId.toInt32(), Properties.Settings.Default.Connection))
         {
             if (ORMForSDF.DeleteFromDatabase("Box", "Id", iBoxId.toInt32(), Properties.Settings.Default.Connection))
             {
                 btnClear_Click(null, null);
             }
         }
     }
 }
Beispiel #8
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (Messages.DeleteConfirmationMessage() && iStaffId != null)
     {
         if (db.Transactions.Where(x => x.FK_Staff == iStaffId).ToList().Count > 0)
         {
             Messages.ReferenceExistsMessage(); return;
         }
         if (ORMForSDF.DeleteFromDatabase("Staff", "Id", iStaffId.toInt32(), Properties.Settings.Default.Connection))
         {
             btnClear_Click(null, null);
         }
     }
 }
Beispiel #9
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtName.Text == string.Empty && slots.Count > 0)
            {
                Messages.ErrorMessage("Please fill the details."); return;
            }
            var box = new Box
            {
                Id         = iBoxId,
                Name       = txtName.Text,
                FK_StaffId = cmbStaff.SelectedValue.ToInt32(),
                CreatedOn  = DateTime.Now.Date
            };

            if (iBoxId == null)
            {
                if (ORMForSDF.InsertToDatabaseObj(box, "Box", Properties.Settings.Default.Connection))
                {
                    box = db.Boxes.FirstOrDefault(x => x.Name == txtName.Text);
                    if (box.Id != null)
                    {
                        foreach (var item in slots)
                        {
                            item.FK_BoxId = box.Id.ToInt32();
                        }
                        ORMForSDF.InsertToDatabase(slots.Cast <object>().ToList(), "Slot", Properties.Settings.Default.Connection);
                        Messages.SavedMessage();
                        btnClear_Click(null, null);
                    }
                }
            }
            else
            {
                if (ORMForSDF.UpdateToDatabaseObj(box, "Box", "Id", iBoxId.toInt32(), Properties.Settings.Default.Connection))
                {
                    if (iBoxId != null)
                    {
                        foreach (var item in slots)
                        {
                            item.FK_BoxId = iBoxId.ToInt32();
                        }
                        ORMForSDF.UpdateDatabase(slots.Cast <object>().ToList(), oldSlots.Cast <object>().ToList(), "Slot", "Id", Properties.Settings.Default.Connection);
                        Messages.UpdateMessage();
                        btnClear_Click(null, null);
                    }
                }
            }
        }
Beispiel #10
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (txtName.Text == string.Empty)
     {
         Messages.ErrorMessage("Please fill the details."); return;
     }
     if (iStaffId == null || !db.Staffs.Any(x => x.Id == iStaffId))
     {
         if (isFirstEntry)
         {
             if (ORMForSDF.InsertToDatabaseObj(new Staff {
                 Id = null, Name = txtName.Text, Password = txtPassword.Text
             }, "Staff", Properties.Settings.Default.Connection))
             {
                 Login frm = new Login();
                 this.Hide();
                 frm.Show();
             }
         }
         else
         {
             if (db.Staffs.FirstOrDefault(x => x.Id == User.iUserId).Name == "Admin")
             {
                 if (ORMForSDF.InsertToDatabaseObj(new Staff {
                     Id = null, Name = txtName.Text, Password = txtPassword.Text
                 }, "Staff", Properties.Settings.Default.Connection))
                 {
                     Messages.SavedMessage(); btnClear_Click(null, null);
                 }
             }
             else
             {
                 Messages.ErrorMessage("Only Admin have power to create new User.");
             }
         }
     }
     else
     {
         if (ORMForSDF.UpdateToDatabaseObj(new Staff {
             Id = iStaffId, Name = txtName.Text, Password = txtPassword.Text
         }, "Staff", "Id", iStaffId.toInt32(), Properties.Settings.Default.Connection))
         {
             Messages.UpdateMessage(); btnClear_Click(null, null);
         }
         ;
     }
 }
Beispiel #11
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (Messages.DeleteConfirmationMessage() && iCustomerId != null)
     {
         foreach (var item in db.Slots.Where(x => x.FK_CustomerId == iCustomerId))
         {
             item.InStatus       = false;
             item.OccupaidStatus = false;
             ORMForSDF.UpdateToDatabaseObj(item, "Slot", "Id", item.Id.toInt32(), Properties.Settings.Default.Connection);
         }
         ORMForSDF.DeleteFromDatabase("Transactions", "FK_Customer", iCustomerId.ToInt32(), Properties.Settings.Default.Connection);
         if (ORMForSDF.DeleteFromDatabase("Customer", "Id", iCustomerId.toInt32(), Properties.Settings.Default.Connection))
         {
             btnClear_Click(null, null);
         }
     }
 }
Beispiel #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);
            }
        }