private void btnAdd_Click(object sender, EventArgs e)
        {
            string error = ValidateFields();

            if (string.IsNullOrEmpty(error))
            {
                using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
                {
                    try
                    {
                        var result = context.INS_Company(txtCompanyName.Text,
                                                         txtDealerName.Text,
                                                         txtAddress.Text,
                                                         Convert.ToInt64(txtMobile.Text)
                                                         );
                        FillCompanyList();
                        txtCompanyName.Clear();
                        txtAddress.Clear();
                        txtDealerName.Clear();
                        txtMobile.Clear();
                        MessageBox.Show(Constants.COMPANY_ADD_SUCCESS);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Constants.COMPANY_FAILURE);
                    }
                }
            }
            else
            {
                MessageBox.Show(error);
            }
        }
Example #2
0
        private void btnAddStock_Click(object sender, EventArgs e)
        {
            string error = ValidateFields();

            if (string.IsNullOrEmpty(error))
            {
                try
                {
                    using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
                    {
                        var result = context.INS_StockIn(txtSItem.Text, Constants.ADD, Convert.ToInt32(txtSQuantity.Text),
                                                         Convert.ToInt32(txtSPrice.Text), Convert.ToInt32(cmbCompanies.SelectedValue.ToString()), Convert.ToDateTime(dtEdate.Value.ToShortDateString()), Convert.ToDateTime(DateTime.Now), LoginUC.employeeName);
                        MessageBox.Show(Constants.STOCK_ADD);
                        ClearAddStockFields();
                        BindStocks();
                        txtIQuantity.Text    = GetQuantity(Convert.ToInt32(((System.Collections.Generic.KeyValuePair <string, string>)cboIName.SelectedItem).Key)).ToString();
                        txtItemQuantity.Text = GetQuantity(Convert.ToInt32(((System.Collections.Generic.KeyValuePair <string, string>)cboItemName.SelectedItem).Key)).ToString();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Constants.STOCK_ADD_FAIL);
                }
            }
            else
            {
                MessageBox.Show(error);
            }
        }
        private void FillCompanyList()
        {
            using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
            {
                var companyList = context.GET_Companies().ToList();
                if (companyList.Count > 0)
                {
                    dgCompanyList.DataSource         = companyList;
                    dgCompanyList.Columns[0].Visible = false;
                    dgCompanyList.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);

                    Dictionary <string, string> item = new Dictionary <string, string>();
                    foreach (var c in companyList)
                    {
                        item.Add(c.Id.ToString(), c.CompanyName);
                    }
                    cmbCompanies.DataSource    = new BindingSource(item, null);
                    cmbCompanies.DisplayMember = "Value";
                    cmbCompanies.ValueMember   = "Key";
                }
                else
                {
                    cmbCompanies.DataSource  = null;
                    dgCompanyList.DataSource = null;
                }
            }
        }
Example #4
0
 private void btnUpdateStock_Click(object sender, EventArgs e)
 {
     if (cboItemName.Items.Count > 0)
     {
         string error = ValidateUpdateFields();
         if (string.IsNullOrEmpty(error))
         {
             MessageBox.Show(Constants.STOCK_UPDATE_WARNING);
             using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
             {
                 var text   = ((System.Collections.Generic.KeyValuePair <string, string>)cboIName.SelectedItem).Value;
                 var result = context.UPD_StockIn(Convert.ToInt32(cboIName.SelectedValue.ToString()), text, Convert.ToInt32(txtItQuantity.Text), Convert.ToInt32(txtItPrice.Text)
                                                  , Constants.UPDATE, Convert.ToDateTime(DateTime.Now), LoginUC.employeeName);
             }
             MessageBox.Show(Constants.STOCK_UPDATE_SUCCESS);
             BindStocks();
             txtItQuantity.Clear();
             txtItPrice.Clear();
         }
         else
         {
             MessageBox.Show(error);
         }
     }
     else
     {
         MessageBox.Show(Constants.NO_STOCK);
     }
 }
Example #5
0
 private void BindStocks()
 {
     using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
     {
         stockDetails = context.GET_StockDetails().ToList();
         if (stockDetails.Count > 0)
         {
             Dictionary <string, string> item = new Dictionary <string, string>();
             foreach (var s in stockDetails)
             {
                 item.Add(s.S_Id.ToString(), s.S_Name);
             }
             cboIName.DataSource                    = new BindingSource(item, null);
             cboIName.DisplayMember                 = "Value";
             cboIName.ValueMember                   = "Key";
             cboItemName.DataSource                 = new BindingSource(item, null);
             cboItemName.DisplayMember              = "Value";
             cboItemName.ValueMember                = "Key";
             this.cboIName.SelectedIndexChanged    += new System.EventHandler(cboIName_SelectedIndexChanged);
             this.cboItemName.SelectedIndexChanged += new System.EventHandler(cboItemName_SelectedIndexChanged);
             dgViewStock.DataSource                 = stockDetails;
             dgViewStock.Columns[0].Visible         = false;
         }
         else
         {
             cboIName.DataSource    = null;
             cboItemName.DataSource = null;
             dgViewStock.DataSource = null;
         }
     }
 }
Example #6
0
 private void GetAllEmployees()
 {
     using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
     {
         var employeeList = context.GET_Employees().ToList();
         dgViewEmp.DataSource = employeeList;
         dgViewEmp.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
     }
 }
Example #7
0
 private void BindStocks()
 {
     using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
     {
         stockdetails = context.GET_StockDetails().ToList();
         Dictionary <string, string> item = new Dictionary <string, string>();
         foreach (var s in stockdetails)
         {
             item.Add(s.S_Id.ToString(), s.S_Name);
         }
         cmbItemName.DataSource                 = new BindingSource(item, null);
         cmbItemName.DisplayMember              = "Value";
         cmbItemName.ValueMember                = "Key";
         this.cmbItemName.SelectedIndexChanged += new System.EventHandler(cmbItemName_SelectedIndexChanged);
     }
 }
Example #8
0
        public void GetAllEmployeeLookUpData()
        {
            using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
            {
                var employyeLookUp = context.GET_Employee_LookUp().ToList();

                Dictionary <string, string> item = new Dictionary <string, string>();
                foreach (var c in employyeLookUp)
                {
                    item.Add(c.Id.ToString(), c.Type);
                }
                cmbDesignation.DataSource    = new BindingSource(item, null);
                cmbDesignation.DisplayMember = "Value";
                cmbDesignation.ValueMember   = "Key";
            }
        }
Example #9
0
        private void btnRegister_Click(object sender, EventArgs e)
        {
            string error = ValidateFields();

            if (string.IsNullOrEmpty(error))
            {
                try
                {
                    int employeeId = 0;
                    using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
                    {
                        System.Data.Entity.Core.Objects.ObjectParameter objParam = new System.Data.Entity.Core.Objects.ObjectParameter("eid", typeof(Int32));
                        var eid = context.INS_Employee(txtFName.Text, txtLName.Text, txtAddress.Text, Convert.ToInt64(txtMobile.Text), Convert.ToInt32(cmbDesignation.SelectedValue)
                                                       , Convert.ToInt32(txtSalary.Text), objParam);
                        employeeId = Convert.ToInt32(objParam.Value);
                    }
                    if (employeeId > 0)
                    {
                        using (MedicalDBEntityModelConnection loginContext = new MedicalDBEntityModelConnection())
                        {
                            string loginId  = txtFName.Text + CommonHelper.GenerateRandomNo();
                            string password = Constants.PASS + CommonHelper.GenerateRandomNo();
                            var    aaa      = loginContext.INS_Login(loginId, password, employeeId);
                            MessageBox.Show(Constants.REGISTRATION_SUCCESS + Environment.NewLine +
                                            Constants.LOGIN_ID + loginId + Environment.NewLine +
                                            Constants.PASSWORD + password + Environment.NewLine);
                        }
                        GetAllEmployees();
                    }
                    else
                    {
                        MessageBox.Show(Constants.REGISTRATION_FAILED);
                    }
                    ClearAllFields();
                }
                catch (Exception ex)
                {
                    ClearAllFields();
                    MessageBox.Show(Constants.REGISTRATION_FAILED);
                }
            }
            else
            {
                MessageBox.Show(error);
            }
        }
Example #10
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtUName.Text) || String.IsNullOrEmpty(txtPass.Text))
            {
                MessageBox.Show(Constants.INVALID_LOGIN);
            }
            else
            {
                using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
                {
                    var loginResult = context.GET_ValidateLogin(txtUName.Text, txtPass.Text).FirstOrDefault();

                    if (loginResult == null)
                    {
                        MessageBox.Show(Constants.INVALID_LOGIN);
                    }
                    else
                    {
                        employeeType = loginResult.Designation_Id;
                        employeeName = loginResult.FirstName;
                        MasterFrom masterForm  = (MasterFrom)this.Parent.Parent;
                        Label      lblUserName = masterForm.Controls["lblUserName"] as Label;
                        lblUserName.Text = Constants.WELCOME + " " + employeeName;
                        if (parentFormName == null)
                        {
                            return;
                        }
                        else
                        {
                            parentFormName = masterForm;
                        }
                        Panel panelMaster = masterForm.Controls["pnlMaster"] as Panel;

                        panelMaster.Controls.Remove(LoginUC.Instance);
                        HomePage.Instance = null;
                        panelMaster.Controls.Add(HomePage.Instance);
                        HomePage.Instance.BringToFront();
                        BuildMenu(masterForm, employeeType);
                    }
                }
            }
        }
Example #11
0
 private void btnDelStock_Click(object sender, EventArgs e)
 {
     if (cboItemName.Items.Count > 0)
     {
         MessageBox.Show(Constants.STOCK_DEL_WARNING);
         using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
         {
             var text   = ((System.Collections.Generic.KeyValuePair <string, string>)cboItemName.SelectedItem).Value;
             var result = context.DEL_Stock(text, Constants.DELETE, Convert.ToDateTime(DateTime.Now), LoginUC.employeeName);
         }
         MessageBox.Show(Constants.STOCK_DEL_SUCCESS);
         BindStocks();
     }
     else
     {
         cboIName.DataSource    = null;
         cboItemName.DataSource = null;
         dgViewStock.DataSource = null;
         MessageBox.Show(Constants.NO_STOCK);
     }
 }
Example #12
0
 private void btnDel_Click(object sender, EventArgs e)
 {
     if (cmbCompanies.Items.Count > 0)
     {
         using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
         {
             try
             {
                 var result = context.DEL_Company(Convert.ToInt32(cmbCompanies.SelectedValue.ToString()));
                 FillCompanyList();
                 MessageBox.Show(Constants.COMPANY_DEL_SUCCESS);
             }
             catch (Exception ex)
             {
                 MessageBox.Show(Constants.COMPANY_FAILURE);
             }
         }
     }
     else
     {
         MessageBox.Show(Constants.COMPANY_NONE);
     }
 }
Example #13
0
 private void FillCompanyList()
 {
     using (MedicalDBEntityModelConnection context = new MedicalDBEntityModelConnection())
     {
         var companyList = context.GET_Companies().ToList();
         if (companyList.Count > 0)
         {
             Dictionary <string, string> item = new Dictionary <string, string>();
             foreach (var c in companyList)
             {
                 item.Add(c.Id.ToString(), c.CompanyName);
             }
             cmbCompanies.DataSource    = new BindingSource(item, null);
             cmbCompanies.DisplayMember = "Value";
             cmbCompanies.ValueMember   = "Key";
         }
         else
         {
             dgViewStock.DataSource  = null;
             cmbCompanies.DataSource = null;
             MessageBox.Show(Constants.COMPANY_NONE);
         }
     }
 }