Esempio n. 1
0
 private void GenerateDataWithOutNoOfLeaves()
 {
     try
     {
         int employeeid = Convert.ToInt32(Session["currentpayslipemployeeid"]);
         lblDeductionForLeaves.Text = "";
         lblNetSalary.Text          = "";
         if (txtNoOfLeaves.Text.Length <= 0)
         {
             txtNoOfLeaves.Text = "0";
         }
         int noofleaves = Convert.ToInt32(txtNoOfLeaves.Text);
         if (noofleaves >= 0 && noofleaves <= 31)
         {
             DataTable dt1                = BusinessAccessLayer.Query("select * from employees e,levels l where e.levelid=l.levelid and employeeid=" + employeeid);
             decimal   basicsalary        = Convert.ToDecimal(dt1.Rows[0]["basicsalary"]);
             int       daysinmonth        = DateTime.DaysInMonth(Convert.ToInt32(dropYear.SelectedItem.Text), dropMonth.SelectedIndex + 1);
             decimal   salaryperday       = basicsalary / daysinmonth;
             decimal   deductionforleaves = noofleaves * salaryperday;
             decimal   netsalary          = basicsalary - deductionforleaves;
             lblSalaryPerDay.Text       = Math.Round(salaryperday, 2).ToString();
             lblDeductionForLeaves.Text = Math.Round(deductionforleaves, 2).ToString();
             lblNetSalary.Text          = Math.Round(netsalary, 2).ToString();
         }
         txtNoOfLeaves.Focus();
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
 void RefreshData()
 {
     UserSource.DataSource      = BusinessAccessLayer.GetEntity().User_tbl;
     DBSource.DataSource        = BusinessAccessLayer.GetEntity().DB_tbl;
     SubPrivSource.DataSource   = BusinessAccessLayer.GetEntity().Sub_Priv_tbl;
     PrivelegeSource.DataSource = BusinessAccessLayer.GetEntity().Privilege_tbl;
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            var checkAdd    = checkBox1.Checked;
            var checkedit   = checkBox2.Checked;
            var checkDelete = checkBox3.Checked;
            var checkView   = checkBox4.Checked;
            var selectDB    = int.Parse(comboBox1.SelectedValue.ToString());

            AsyncHelper.TaskAwaiter(() =>
            {
                var user = (User_tbl)UserSource.Current;

                var priv = user.Privilege_tbl.Where(x => x.DbID == selectDB);
                if (priv.Count() <= 0)
                {
                    var subpriv = new Sub_Priv_tbl
                    {
                        Add    = checkAdd,
                        Edit   = checkedit,
                        Delete = checkDelete,
                        View   = checkView
                    };

                    var privNew          = new Privilege_tbl();
                    privNew.DbID         = selectDB;
                    privNew.Sub_Priv_tbl = subpriv;

                    user.Privilege_tbl.Add(privNew);
                }

                BusinessAccessLayer.GetEntity().SaveChanges();
                return(true);
            });
        }
Esempio n. 4
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     BusinessAccessLayer.GetEntity().SaveChanges();
     modRefreshData("");
     Close();
     Dispose();
 }
Esempio n. 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Page.IsPostBack == false)
         {
             for (int i = DateTime.Now.Year; i >= 1950; i--)
             {
                 dropYear.Items.Add(i.ToString());
             }
             int       employeeid = Convert.ToInt32(Session["currentpayslipemployeeid"]);
             DataTable dt         = BusinessAccessLayer.Query("select * from employees e,levels l where e.levelid=l.levelid and employeeid=" + employeeid);
             if (dt.Rows.Count > 0)
             {
                 lblEmployee.Text    = Convert.ToString(dt.Rows[0]["name"]);
                 lblBasicSalary.Text = Convert.ToString(dt.Rows[0]["basicsalary"]);
                 DateTime date = DateTime.Now.AddMonths(-1);
                 dropMonth.SelectedIndex = date.Month - 1;
                 dropYear.SelectedIndex  = dropYear.Items.IndexOf(new ListItem(date.Year.ToString()));
                 GenerateData();
                 txtNoOfLeaves.Focus();
             }
             else
             {
                 Response.Redirect("payslips.aspx", false);
             }
         }
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
 private void Show()
 {
     try
     {
         lnkGeneratePayslip.Visible = false;
         gridPayslips.DataSource    = null;
         gridPayslips.DataBind();
         lblMessage.Text = "";
         if (dropEmployee.SelectedIndex > 0)
         {
             lnkGeneratePayslip.Visible = true;
             string    employeename = dropEmployee.SelectedItem.Text;
             int       employeeid   = Convert.ToInt32(BusinessAccessLayer.Query("select employeeid from employees where name='" + employeename + "'").Rows[0]["employeeid"]);
             DataTable dt           = BusinessAccessLayer.Query("select payslipid,monthname + ' ' + convert(varchar,year) 'MonthAndYear',generatedon,basicsalary,noofleaves,salaryperday,deductionforleaves,netsalary from payslips ps where employeeid=" + employeeid + " order by year desc,ps.month desc");
             if (dt.Rows.Count > 0)
             {
                 gridPayslips.DataSource = dt;
                 gridPayslips.DataBind();
             }
             else
             {
                 lblMessage.Text = "No payslips found.";
             }
         }
         dropEmployee.Focus();
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
        public void RefreshData(string msg)
        {
            var entity = BusinessAccessLayer.GetEntity();

            entity.CreateDatabaseScript();
            SupplierSource.DataSource = entity.Suppliers;
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Convert.ToString(Session["currentusertype"]) != "Administrator")
         {
             Response.Redirect("welcome.aspx");
         }
         if (Page.IsPostBack == false)
         {
             dropLevel.Items.Clear();
             DataTable dt = BusinessAccessLayer.Query("select * from levels order by levelid");
             if (dt.Rows.Count > 0)
             {
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     dropLevel.Items.Add(Convert.ToString(dt.Rows[i]["levelid"]));
                 }
                 dropLevel.SelectedIndex = 0;
             }
             else
             {
                 Response.Redirect("welcome.aspx", false);
             }
             int newemployeeid = BusinessAccessLayer.GetNextID("employees", "employeeid");
             lblEmployeeID.Text = Convert.ToString(newemployeeid);
             txtName.Focus();
         }
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
        private void textBox1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                var products = BusinessAccessLayer.GetEntity().Products.Where(x => x.ProductName.Contains(textBox1.Text.Trim()));

                if (products.Count() <= 0)
                {
                    MessageBox.Show("Product Barcode not available", "invalid", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                    return;
                }
                _orderDetails           = new Order_Detail();
                _orderDetails.Quantity  = 1;
                _orderDetails.UnitPrice = products.First().UnitPrice;
                _orderDetails.ProductID = products.First().ProductID;
                _orderDetails.IsVoid    = false;
                _orderDetails.IsReturn  = false;

                OrderDetailSource.Add(_orderDetails);

                CalculateSumAmount();
                textBox11.Clear();
                textBox11.Focus();
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            if (txtGrandtotal.Text.Trim() == "")
            {
                return;
            }

            var result = MessageBox.Show(
                "You must save the transaction before you cant generate Invoice\nDo you want to save transaction?",
                "Saving transaction", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

            if (result == DialogResult.Yes)
            {
                _order.CustomerID      = int.Parse(cmbBillto.SelectedValue.ToString() ?? "0");
                _order.IsPaid          = false;
                _order.OrderDate       = DateTime.Now;
                _order.BillingDate     = dtpTransDate.Value.AddDays(30);
                _order.DeliveryAddress = txtAddress.Text;
                _order.DeliveryDate    = dtpTransDate.Value;
                _order.Term            = 30;

                foreach (var orderDetail in OrderDetailSource.OfType <Order_Detail>())
                {
                    _order.Order_Details.Add(orderDetail);
                }

                BusinessAccessLayer.GetEntity().Orders.AddObject(_order);
                BusinessAccessLayer.GetEntity().SaveChanges();

                GenerateInvoice();

                Close();
            }
        }
 public frmTransactionBilling()
 {
     InitializeComponent();
     _order = new Order();
     OrderSource.DataSource    = BusinessAccessLayer.GetEntity().Orders;
     CustomerSource.DataSource = BusinessAccessLayer.GetEntity().Customers;
     ProductSource.DataSource  = BusinessAccessLayer.GetEntity().Products;
 }
        public frmTransactionDelivery()
        {
            InitializeComponent();
            _order = new Order();
            OrderSource.DataSource    = BusinessAccessLayer.GetEntity().Orders;
            CustomerSource.DataSource = BusinessAccessLayer.GetEntity().Customers;
            ProductSource.DataSource  = BusinessAccessLayer.GetEntity().Products;

            textBox11.Focus();
        }
        private frmCustomerDataEntry(int id = 0)
        {
            InitializeComponent();

            if (id <= 0)
            {
                CustomerSource.DataSource = BusinessAccessLayer.GetEntity().Products;
            }
            else
            {
                CustomerSource.DataSource = BusinessAccessLayer.GetEntity().Customers.Where(e => e.ID == id);
            }
        }
Esempio n. 14
0
        private frmProductDataEntry(int id = 0)
        {
            InitializeComponent();

            bindingSupplier.DataSource = BusinessAccessLayer.GetEntity().Suppliers;
            if (id <= 0)
            {
                bindingProduct.DataSource = BusinessAccessLayer.GetEntity().Products;
            }
            else
            {
                bindingProduct.DataSource = BusinessAccessLayer.GetEntity().Products.Where(e => e.ProductID == id);
            }
        }
        private frmSupplierDataEntry(int id = 0)
        {
            InitializeComponent();


            if (id <= 0)
            {
                SupplierSource.DataSource = BusinessAccessLayer.GetEntity().Suppliers;
            }
            else
            {
                SupplierSource.DataSource = BusinessAccessLayer.GetEntity().Suppliers.Where(e => e.SupplierID == id);
            }
        }
Esempio n. 16
0
 protected void gridMessages_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         int    messageid = Convert.ToInt32(gridMessages.Rows[e.RowIndex].Cells[0].Text);
         string sqlstr    = "update messages set active=0 where messageid=" + messageid;
         BusinessAccessLayer.NonQuery(sqlstr);
         Show();
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
Esempio n. 17
0
 protected void gridPayslips_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     try
     {
         int    payslipid = Convert.ToInt32(gridPayslips.Rows[e.RowIndex].Cells[0].Text);
         string sqlstr    = "delete from payslips where payslipid=" + payslipid;
         BusinessAccessLayer.NonQuery(sqlstr);
         Show();
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
        private void OnChangeDataSelect()
        {
            var user  = (User_tbl)UserSource.Current;
            var Dbtbl = (DB_tbl)DBSource.Current;

            var checkAdd    = checkBox1.Checked;
            var checkedit   = checkBox2.Checked;
            var checkDelete = checkBox3.Checked;
            var checkView   = checkBox4.Checked;
            var selectDB    = int.Parse(comboBox1.SelectedValue.ToString());

            var dataAwaiter = AsyncHelper.TaskAwaiter(() =>
            {
                var privList =
                    BusinessAccessLayer.GetEntity().Privilege_tbl.Where(x => x.UserID == user.ID && x.DbID == Dbtbl.ID);


                if (privList.Count() <= 0)
                {
                    var subpriv = new Sub_Priv_tbl
                    {
                        Add    = checkAdd,
                        Edit   = checkedit,
                        Delete = checkDelete,
                        View   = checkView
                    };

                    var privNew          = new Privilege_tbl();
                    privNew.DbID         = selectDB;
                    privNew.Sub_Priv_tbl = subpriv;

                    user.Privilege_tbl.Add(privNew);
                    BusinessAccessLayer.GetEntity().SaveChanges();

                    privList =
                        BusinessAccessLayer.GetEntity().Privilege_tbl.Where(x => x.UserID == user.ID && x.DbID == Dbtbl.ID);
                }
                return(privList);
            });

            dataAwaiter.OnCompleted(() =>
            {
                var privList = dataAwaiter.GetResult();
                if (privList.Count() > 0)
                {
                    SubPrivSource.DataSource = privList.First().Sub_Priv_tbl;
                }
            });
        }
Esempio n. 19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         //if (Convert.ToString(Session["currentusertype"]) != "Manager")
         //   Response.Redirect("welcome.aspx");
         DataTable dt = BusinessAccessLayer.Query("select * from employees order by employeeid");
         gridEmployees.DataSource = dt;
         gridEmployees.DataBind();
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
 protected void lnkYes_Click(object sender, EventArgs e)
 {
     try
     {
         int    employeeid = Convert.ToInt32(Session["deletingemployeeid"]);
         string sqlstr     = "delete from employees where employeeid=" + employeeid;
         BusinessAccessLayer.NonQuery(sqlstr);
         Session["deletingemployeeid"] = null;
         Response.Redirect("employees.aspx", false);
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Convert.ToString(Session["currentusertype"]) != "Manager")
         {
             Response.Redirect("welcome.aspx");
         }
         if (Page.IsPostBack == false)
         {
             dropTo.Focus();
             dropTo.Items.Clear();
             dropTo.Items.Add("---Select---");
             DataTable dt = BusinessAccessLayer.Query("select * from employees order by levelid");
             if (dt.Rows.Count > 0)
             {
                 for (int i = 0; i < dt.Rows.Count; i++)
                 {
                     dropTo.Items.Add(Convert.ToString(dt.Rows[i]["name"]));
                 }
                 dropTo.SelectedIndex = 0;
                 if (Session["replyemployeename"] != null && Convert.ToString(Session["replyemployeename"]) != "")
                 {
                     int n = 0;
                     for (int i = 0; i < dropTo.Items.Count; i++)
                     {
                         if (Convert.ToString(Session["replyemployeename"]) == dropTo.Items[i].Text)
                         {
                             n = i;
                         }
                     }
                     Session["replyemployeename"] = null;
                     dropTo.SelectedIndex         = n;
                     txtMessage.Focus();
                 }
             }
             else
             {
                 Response.Redirect("welcome.aspx", false);
             }
         }
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
Esempio n. 22
0
 protected void lnkGeneratePayslip_Click(object sender, EventArgs e)
 {
     try
     {
         if (dropEmployee.SelectedIndex > 0)
         {
             string employeename = dropEmployee.SelectedItem.Text;
             int    employeeid   = Convert.ToInt32(BusinessAccessLayer.Query("select employeeid from employees where name='" + employeename + "'").Rows[0]["employeeid"]);
             Session["currentpayslipemployeeid"] = employeeid;
             Response.Redirect("generatepayslip.aspx", false);
         }
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
Esempio n. 23
0
    private void Show()
    {
        gridMessages.DataSource = null;
        gridMessages.DataBind();
        lblMessage.Text = "";
        DataTable dt = BusinessAccessLayer.Query("select * from messages where messagefrom='" + from + "' order by date desc");

        if (dt.Rows.Count > 0)
        {
            gridMessages.DataSource = dt;
            gridMessages.DataBind();
        }
        else
        {
            lblMessage.Text = "No Messages.";
        }
    }
Esempio n. 24
0
        //Use to validate user login entry
        private void sValidate()
        {
            var user =
                BusinessAccessLayer.GetEntity().User_tbl.Where(
                    e => e.UserID == txtUsername.Text && e.Password == txtPassword.Text);


            if (user.Count() > 0)
            {
                isvalid = true;
                User    = txtUsername.Text;
                Close();
                return;
            }

            MessageBox.Show("Invalid username or password", "invalid", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Esempio n. 25
0
        public frmRemittance(int id = 0)
        {
            InitializeComponent();

            UserSource.DataSource = BusinessAccessLayer.GetEntity().User_tbl;

            var ordersPaid =
                BusinessAccessLayer.GetEntity().Orders.ToList().Where(
                    e => (e.OrderDate >= DateTime.Now.AddHours(-8) && e.OrderDate <= DateTime.Now) ||
                    (e.DeliveryDate >= DateTime.Now.AddHours(-8) && e.DeliveryDate <= DateTime.Now));

            decimal?totalRemit = null;

            totalRemit = ordersPaid.Sum(e => e.Payments.Sum(x => x.AmountPaid));

            label3.Text = (totalRemit ?? 0).ToString("#,###.00");
        }
        public frmManageUser()
        {
            InitializeComponent();

            var userCount = BusinessAccessLayer.GetEntity().User_tbl.Count();

            if (userCount <= 0)
            {
                var user = new User_tbl();
                user.UserID   = "Admin";
                user.Password = "******";
                BusinessAccessLayer.GetEntity().User_tbl.AddObject(user);
                BusinessAccessLayer.GetEntity().SaveChanges();
            }

            RefreshData();
            comboBox1.SelectedValueChanged += comboBox1_SelectedValueChanged;
        }
Esempio n. 27
0
    private void Show()
    {
        gridMessages.DataSource = null;
        gridMessages.DataBind();
        lblMessage.Text = "";
        int       to = Convert.ToInt32(Session["currentemployeeid"]);
        DataTable dt = BusinessAccessLayer.Query("select * from messages where messagefrom='Manager' and employeeid=" + to + " and active=1 order by date desc");

        if (dt.Rows.Count > 0)
        {
            gridMessages.DataSource = dt;
            gridMessages.DataBind();
        }
        else
        {
            lblMessage.Text = "No Messages.";
        }
    }
Esempio n. 28
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            var remitttance = new Remittance();

            remitttance.DateRemit = DateTime.Now;
            remitttance.UserID    = int.Parse(comboBox1.SelectedValue.ToString());

            foreach (var remittanceDetail in RemitDetailSource.OfType <RemittanceDetail>())
            {
                remitttance.RemittanceDetails.Add(remittanceDetail);
            }


            BusinessAccessLayer.GetEntity().Remittances.AddObject(remitttance);
            BusinessAccessLayer.GetEntity().SaveChanges();
            Close();
            Dispose();
        }
 protected void btnSubmit_Click(object sender, EventArgs e)
 {
     try
     {
         string date, messagefrom, messageto, message;
         int    employeeid;
         date        = DateTime.Now.ToString();
         messagefrom = Convert.ToString(Session["currentemployeename"]);
         messageto   = "Manager";
         message     = txtMessage.Text;
         employeeid  = Convert.ToInt32(Session["currentemployeeid"]);
         string sqlstr = "insert into messages values('" + date + "','" + messagefrom + "','" + messageto + "','" + message + "'," + employeeid + ",1)";
         BusinessAccessLayer.NonQuery(sqlstr);
         Response.Redirect("employeemessageoutbox.aspx", false);
     }
     catch (Exception ex)
     {
         lblError.Text = "Error: " + ex.Message;
     }
 }
        public frmTransactionBilling(int id)
        {
            InitializeComponent();
            _order = new Order();

            if (BusinessAccessLayer.GetEntity().Orders.Where(e => e.OrderID == id).Count() <= 0)
            {
                MessageBox.Show("Order Transaction doesnt exist", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            _order = BusinessAccessLayer.GetEntity().Orders.Where(e => e.OrderID == id).First();

            OrderSource.DataSource       = _order;
            CustomerSource.DataSource    = _order.Customer;
            ProductSource.DataSource     = BusinessAccessLayer.GetEntity().Products;
            OrderDetailSource.DataSource = _order.Order_Details;

            CalculateSumAmount();
        }