Exemplo n.º 1
0
        private void gvMRList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex >= 0)
                {
                    bindItemList.DataSource = null;
                    long MRNO      = Convert.ToInt64(gvMRList.Rows[e.RowIndex].Cells["MRNO"].Value);
                    MR   objMRTemp = objMRDL.Get(MRNO);

                    objMR = new MR();
                    objMR = objMRTemp;


                    Load_MRItem();


                    txtDepartment.Text = objMR.MRDepartmentFrom.DepName;

                    ItemSelect = true;

                    Section_DL objSectionDL = new Section_DL(ConnectionStringClass.GetConnection());
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 2
0
        private void frmCosting_Load(object sender, EventArgs e)
        {
            StockHoldingRate_DL objStockHoldingRateDL = new StockHoldingRate_DL(ConnectionStringClass.GetConnection());
            Employee_DL         objEmpDL      = new Employee_DL(ConnectionStringClass.GetConnection());
            Department_DL       objDepDL      = new Department_DL(ConnectionStringClass.GetConnection());
            Section_DL          objSection_DL = new Section_DL(ConnectionStringClass.GetConnection());

            try
            {
                StockHoldingRate obj = new StockHoldingRate();
                obj = objStockHoldingRateDL.GetFinal();
                Employee objChangedBy = objEmpDL.Get(obj.ChangedBy);
                txtEnterdBy.Text            = objChangedBy.EmployeeName;
                txtEnterdDate.Text          = obj.FromDate.Value.ToShortDateString();
                txtCurrentRate.Text         = obj.Cost.ToString();
                bindStockHolding.DataSource = objStockHoldingRateDL.Get();

                bindDepartment.DataSource = objSection_DL.GetDataView();
                objCompanyOverHeadRate    = objCompanyOverHeadRate_DL.Get();

                if (objCompanyOverHeadRate != null)
                {
                    txtComDate.Text   = objCompanyOverHeadRate.EnterdDate.ToShortDateString();
                    txtComEnterd.Text = objCompanyOverHeadRate.EnterdBy.EmployeeNameID;
                    txtComRate.Text   = objCompanyOverHeadRate.Rate.ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        private void gvPackingType_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex >= 0)
            {
                PackingType_DL objPackingTypeDL = new PackingType_DL(ConnectionStringClass.GetConnection());
                Form_DL        objFormDL        = new Form_DL(ConnectionStringClass.GetConnection());
                Unit_DL        objUnitDL        = new Unit_DL(ConnectionStringClass.GetConnection());
                try
                {
                    txtPackingID.Text = Convert.ToString(gvPackingType.CurrentRow.Cells["ColPackingID"].Value);

                    objSelectedPackingType.Type         = Convert.ToString(gvPackingType.Rows[e.RowIndex].Cells["ColType"].Value);
                    objSelectedPackingType.PackingID    = Convert.ToInt64(gvPackingType.Rows[e.RowIndex].Cells["ColPackingID"].Value);
                    objSelectedPackingType.PackingQty   = Convert.ToDecimal(gvPackingType.Rows[e.RowIndex].Cells["ColPackingQty"].Value);
                    objSelectedPackingType.PackingTitle = gvPackingType.Rows[e.RowIndex].Cells["ColPackingTitle"].Value.ToString();
                    objSelectedPackingType.PackingUnit  = objUnitDL.Get(Convert.ToInt64(gvPackingType.Rows[e.RowIndex].Cells["colPackingUnitID"].Value));

                    txtPackingTypeName.Text = objSelectedPackingType.PackingTitle;
                    txtPackingTypeSize.Text = objSelectedPackingType.PackingQty.ToString();
                    cmbUnit.SelectedValue   = objSelectedPackingType.PackingUnit.UnitID.ToString();

                    this.PackingTypeSelect = true;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                DispatchNote_DL     objDispatchNote_DL     = new DispatchNote_DL(ConnectionStringClass.GetConnection());
                DispatchNoteList_DL objDispatchNoteList_DL = new DispatchNoteList_DL(ConnectionStringClass.GetConnection());

                DispatchNote objDispatchNote = new DispatchNote();
                objDispatchNote.DispatchID    = txtDiaptchNote.Text;
                objDispatchNote.DistributorID = cmbDistributor.SelectedValue.ToString();
                objDispatchNote.EnteredBy     = CurrentUser.EmployeeID;

                int x = objDispatchNote_DL.Add(objDispatchNote);

                if (x > 0)
                {
                    foreach (DispatchNoteList _obj in objCollec)
                    {
                        objDispatchNoteList_DL.Add(_obj, StoreID);
                    }

                    MessageBox.Show("Successfully Saved");

                    Clear_Data();
                }
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 5
0
        private void button10_Click(object sender, EventArgs e)
        {
            if (this.ProductSelect)
            {
                DialogResult dr = MessageBox.Show(this, "Are you sure, You want to Delete selected Record?", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    BasicProduct_DL objbasicProduct = new BasicProduct_DL(ConnectionStringClass.GetConnection());
                    try
                    {
                        int x = objbasicProductDL.Delete(txtProductCode.Text);
                        BasicProductBinidinSourse.DataSource = objbasicProductDL.GetDataView_By_Category(cmbCategory.SelectedValue.ToString());


                        this.ProductSelect = false;
                        if (x > 0)
                        {
                            MessageBox.Show(this, "Succesfully Deleted From Database", "Succesfull", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.ClearBasicProduct();
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                MessageBox.Show(this, "Select a Record from the List", "Select a Record", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 6
0
 private void txtmat_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.KeyCode == Keys.Down)
         {
             gvMaterials.Focus();
         }
         else if (e.KeyCode == Keys.Escape)
         {
             this.Close();
         }
         else if (e.KeyCode == Keys.Enter)
         {
             try
             {
                 e.Handled = true;
                 Material_DL objMatDL = new Material_DL(ConnectionStringClass.GetConnection());
                 Material = objMatDL.Get(gvMaterials.SelectedRows[0].Cells["Column1"].Value.ToString());
                 this.Close();
             }
             catch (Exception)
             {
                 MessageBox.Show(this, "Error Occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
         }
     }
     catch (Exception)
     {
         MessageBox.Show(this, "Error occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemplo n.º 7
0
 public void LoadForm(String EmpRole)
 {
     objSectionDL          = new Section_DL(ConnectionStringClass.GetConnection());
     objEmployeeDL         = new Employee_DL(ConnectionStringClass.GetConnection());
     cmbSection.DataSource = objSectionDL.GetDataView();
     EmployeeRole          = EmpRole;
 }
Exemplo n.º 8
0
        private void btnApprove_Click(object sender, EventArgs e)
        {
            MTNMaterial_DL      objMTNMatDL    = new MTNMaterial_DL(ConnectionStringClass.GetConnection());
            MTNBasicProduct_DL  objMTNBasicDL  = new MTNBasicProduct_DL(ConnectionStringClass.GetConnection());
            MTNFinishProduct_DL objMTNFinishDL = new MTNFinishProduct_DL(ConnectionStringClass.GetConnection());

            try
            {
                DialogResult dr = MessageBox.Show(this, "Do you want to Approve Selected MTN? Click Yes to Approve", "Approve MTN?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dr == DialogResult.Yes)
                {
                    objMTN.MTNStatus     = MTN.Status.Approved;
                    objMTN.MTNApprovedBy = CurrentUser.UserEmp;

                    objMTNDL.Update(objMTN);

                    Load_MTN();

                    DataGridViewCellEventArgs er = new DataGridViewCellEventArgs(1, 0);

                    gvMTNList_CellClick(sender, er);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 9
0
        private void btnFinalize_Click(object sender, EventArgs e)
        {
            if (DataValidation.Is3DecimalPointNumber(txtDamagedQty.Text) && DataValidation.Is3DecimalPointNumber(txtBatchUsed.Text))
            {
                try
                {
                    BatchPackingMR   obj = new BatchPackingMR();
                    BatchActivity    objBatchActivity    = new BatchActivity();
                    BatchActivity_DL objBatchActivity_DL = new BatchActivity_DL(ConnectionStringClass.GetConnection());

                    obj = objBatchPackingMR_DL.Get(Convert.ToInt64(cmbMRNO.SelectedValue));

                    objBatchActivity = objBatchActivity_DL.GetByID(Convert.ToInt32(txtPackingBatch.Text));

                    if ((objBatchActivity.BatchActStatus == BatchActivity.Status.Finished) | (objBatchActivity.BatchActStatus == BatchActivity.Status.SecondaryPacking_Finish) | (objBatchActivity.BatchActStatus == BatchActivity.Status.Transferred))
                    {
                        MessageBox.Show("Activity is Already Finished");
                    }
                    else
                    {
                        if (obj.StartQty >= Convert.ToDecimal(txtDamagedQty.Text) + Convert.ToDecimal(txtBatchReturned.Text) + Convert.ToDecimal(txtBatchUsed.Text))
                        {
                            obj.BatchID        = BatchID;
                            obj.BatchDamaged   = Convert.ToDecimal(txtDamagedQty.Text);
                            obj.BatchReturned  = Convert.ToDecimal(txtBatchReturned.Text);
                            obj.BatchUsed      = Convert.ToDecimal(txtBatchUsed.Text);
                            obj.State          = 1;
                            obj.BatchPackingID = Convert.ToInt64(txtPackingBatch.Text);


                            objBatchPackingMR_DL.Update(obj, MTN.Status.Initial, MTN.Type.Reject, MTN.ItemType.Material, CurrentUser.EmployeeID);
                        }
                        else
                        {
                            MessageBox.Show("Invalid Qty");
                        }
                    }

                    Load_MRList();

                    cmbMRNO_SelectedIndexChanged(sender, e);

                    txtBatchReturned.Text = "";
                    txtBatchUsed.Text     = "";
                    txtDamagedQty.Text    = "";

                    txtBatchUsed.Select();
                    loadSectionData();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }
            }
            else
            {
                MessageBox.Show(this, "please enter valid quantity", "MRP System", MessageBoxButtons.OK);
            }
        }
Exemplo n.º 10
0
        private void btnGRN_Click(object sender, EventArgs e)
        {
            try
            {
                objMTN = objMTNDL.Get(objMTN.MTNNo);

                if (objMTN.MTNStatus == MTN.Status.Cost)
                {
                    if ((objMTN != null) && (objStore != null))
                    {
                        if (objMTN.MTNItemType == MTN.ItemType.Material)
                        {
                            PRPDBatch_DL objPRPDBatch_DL = new PRPDBatch_DL(ConnectionStringClass.GetConnection());

                            PRPDBatch objPRPDBatch = objPRPDBatch_DL.Get(gvMTNList.CurrentRow.Cells["BatchID"].Value.ToString());
                            if (objPRPDBatch.Type == PRPDBatch.PRPDType.Rework)
                            {
                                objStore = objStoreDL.Get("RM_Main");
                                long GRNNO = objMTNDL.AddGRN(objMTN.MTNNo, MTN.Status.ReceviedGRN, CurrentUser.EmployeeID, objStore.StoreID, GRN.Type.Material, GRN.Status.Initial);
                                MessageBox.Show(this, "Successfully Raised a GRN. The GRNNO is : " + GRNNO.ToString(), "Successful", MessageBoxButtons.OK);
                            }
                            else
                            {
                                long GRNNO = objMTNDL.AddGRN(objMTN.MTNNo, MTN.Status.ReceviedGRN, CurrentUser.EmployeeID, objStore.StoreID, GRN.Type.Material, GRN.Status.Initial);
                                MessageBox.Show(this, "Successfully Raised a GRN. The GRNNO is : " + GRNNO.ToString(), "Successful", MessageBoxButtons.OK);
                            }
                        }
                        else if (objMTN.MTNItemType == MTN.ItemType.Basic_Product)
                        {
                            long GRNNO = objMTNDL.AddGRN(objMTN.MTNNo, MTN.Status.ReceviedGRN, CurrentUser.EmployeeID, objStore.StoreID, GRN.Type.BasicProduct, GRN.Status.Initial);
                            MessageBox.Show(this, "Successfully Raised a GRN. The GRNNO is : " + GRNNO.ToString(), "Successful", MessageBoxButtons.OK);
                        }
                        else if (objMTN.MTNItemType == MTN.ItemType.Finish_Product)
                        {
                            long GRNNO = objMTNDL.AddGRN(objMTN.MTNNo, MTN.Status.ReceviedGRN, CurrentUser.EmployeeID, objStore.StoreID, GRN.Type.FinishProduct, GRN.Status.Initial);
                            MessageBox.Show(this, "Successfully Raised a GRN. The GRNNO is : " + GRNNO.ToString(), "Successful", MessageBoxButtons.OK);
                        }


                        bindMTNList.DataSource = objMTNDL.Get_From_PRPD_Batches(Convert.ToInt64(MTN.Type.PRPD), Convert.ToInt32(MTN.Status.Cost));

                        if (gvMTNList.Rows.Count > 0)
                        {
                            DataGridViewCellEventArgs dr = new DataGridViewCellEventArgs(1, 0);

                            gvMTNList_CellClick(sender, dr);
                        }
                        else
                        {
                            bindItemList.DataSource = null;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            User    objUser   = new User();
            User_BL objUserBL = new User_BL(ConnectionStringClass.GetConnection());

            try
            {
                objUser = objUserBL.Login(txtUserName.Text, txtPassword.Text);


                if (objUser.UserID == 0)
                {
                    MessageBox.Show(this, "Invalid User Name or Password,Contact System Administrator for more information", "Incorrect User Name or Password", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
                else
                {
                    if (objUser.LastLoggedIn.ToString() == "1/1/0001 12:00:00 AM")
                    {
                        frmChangePassword objFrm = new frmChangePassword(objUser, 0);
                        //Production.BatchFile.frmBatchFile objFrm = new MRP_GUI.Production.BatchFile.frmBatchFile(objUser);
                        objFrm.Show();
                        this.Hide();
                    }
                    else
                    {
                        User_DL objUser_DL = new User_DL(ConnectionStringClass.GetConnection());
                        int     y          = objUser_DL.CheckForPasswordExpiry(objUser);

                        if (y == 1)
                        {
                            frmChangePassword objFrm = new frmChangePassword(objUser, 0);
                            //Production.BatchFile.frmBatchFile objFrm = new MRP_GUI.Production.BatchFile.frmBatchFile(objUser);
                            objFrm.Show();
                            this.Hide();
                        }
                        else
                        {
                            if (objUser.Online == true)
                            {
                                MessageBox.Show(this, "This User has already Logged-In. Please Contact System Administrator", "Already Logged-In", MessageBoxButtons.OK);
                            }
                            else
                            {
                                MRP_Main objFrm = new MRP_Main(objUser);
                                //Production.BatchFile.frmBatchFile objFrm = new MRP_GUI.Production.BatchFile.frmBatchFile(objUser);
                                objFrm.Show();
                                this.Hide();
                                objUser.Online = true;
                                objUser_DL.Update_OnlineState(objUser);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Database error, " + ex.Message, "Logging Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 12
0
 private void Clear()
 {
     txtActivity.Text = "";
     ucSectionFilter1.Load(ConnectionStringClass.GetConnection());
     bindActivity.DataSource   = objManiActDL.Get_Data_View();
     grpMachine.Enabled        = false;
     cmbTemplate.SelectedIndex = 0;
 }
Exemplo n.º 13
0
 public void LoadForm(String EmpRole, String DivisionType)
 {
     objSectionDL  = new Section_DL(ConnectionStringClass.GetConnection());
     objEmployeeDL = new Employee_DL(ConnectionStringClass.GetConnection());
     // cmbSection.DataSource = objSectionDL.Get);
     cmbSection.DataSource = objSectionDL.GetData(DivisionType);
     EmployeeRole          = EmpRole;
 }
Exemplo n.º 14
0
 private void gvMaterials_CellClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         Material_DL objMatDL = new Material_DL(ConnectionStringClass.GetConnection());
         Material = objMatDL.Get(gvMaterials.Rows[e.RowIndex].Cells["Column1"].Value.ToString());
         this.Close();
     }
     catch (Exception)
     {
         MessageBox.Show(this, "Error Occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemplo n.º 15
0
        private void Load_Sections()
        {
            Section_DL objSection_DL = new Section_DL(ConnectionStringClass.GetConnection());

            try
            {
                objSourceSections.DataSource = objSection_DL.GetDataView();
                cmbSections.DataSource       = objSourceSections;
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while loading Section", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 16
0
        private void cmbItem_SelectedIndexChanged(object sender, EventArgs e)
        {
            //txtGRNUnitCost.Text = "0.0";
            //  cmbGRNNO.Text = "";

            Material      objMat     = new Material();
            BasicProduct  objBasic   = new BasicProduct();
            FinishProduct objFinish  = new FinishProduct();
            Store         objStore   = new Store();
            Stock_DL      objStockDL = new Stock_DL(ConnectionStringClass.GetConnection());


            try
            {
                String ItemCode = "";
                txtUnit.Text         = "";
                txtAvailableQty.Text = "";
                if (cmbItem.Items.Count > 0 && cmbItem.SelectedValue != null)
                {
                    ItemCode = cmbItem.SelectedValue.ToString();

                    objStore = (Store)cmbStoreFrom.SelectedItem;
                    if (cmbMTNType.SelectedItem.Equals("Material"))
                    {
                        objMat       = objMaterialDL.Get(ItemCode);
                        txtUnit.Text = objMat.MatUnit.UnitName;
                        //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_Material(objStore.StoreID, ItemCode).ToString();
                        txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.Material).ToString();
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Basic Product"))
                    {
                        objBasic     = objBasicProductDL.Get(ItemCode);
                        txtUnit.Text = objBasic.BasicProductUnit.UnitName;
                        //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_BasicProduct(objStore.StoreID, ItemCode).ToString();
                        txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.BasicProduct).ToString();
                    }
                    else if (cmbMTNType.SelectedItem.Equals("Finish Product"))
                    {
                        objFinish    = objFinishProductDL.Get(ItemCode);
                        txtUnit.Text = objFinish.FinishProductPackingType.PackingTitle;
                        //txtGRNUnitCost.Text = objStockDL.GetAVGUnitPrice_FinishProduct(objStore.StoreID, ItemCode).ToString();
                        txtAvailableQty.Text = objStockDL.GetAvailableQty(objStore.StoreID, ItemCode, Stock.Type.FinishProduct).ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 17
0
 private void frmActivityManagement_Load(object sender, EventArgs e)
 {
     try
     {
         cmbTemplate.DataSource = Enum.GetValues(typeof(MainActivity.LayoutType));
         ucSectionFilter1.Load(ConnectionStringClass.GetConnection());
         bindMachine.DataSource    = objMachine_DL.GetDataView();
         cmbMachineList.DataSource = bindMachine;
         bindActivity.DataSource   = objManiActDL.Get_Data_View();
     }
     catch (Exception ex)
     {
         MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemplo n.º 18
0
 private void cmbDepartment_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         if (cmbDepartment.SelectedValue != null)
         {
             Section_DL objSectionDL = new Section_DL(ConnectionStringClass.GetConnection());
             cmbSection.DataSource = objSectionDL.GetDataView(Convert.ToInt64(cmbDepartment.SelectedValue));
         }
     }
     catch (Exception)
     {
         MessageBox.Show(this, "Error occured while loading Sections", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Exemplo n.º 19
0
        public void LoadUser()
        {
            Employee_DL objEmpDL  = new Employee_DL(ConnectionStringClass.GetConnection());
            User_DL     objUserDL = new User_DL(ConnectionStringClass.GetConnection());

            try
            {
                cmbEmp.DataSource       = objEmpDL.Get();
                bindUserList.DataSource = objUserDL.Get();
                cmbUserRole.DataSource  = objUserRoleDL.GetDataview();
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 20
0
        private void frmAddActivity_Load(object sender, EventArgs e)
        {
            try
            {
                Department_DL objDepartment_DL = new Department_DL(ConnectionStringClass.GetConnection());


                cmbActivity.DataSource     = objMainActivityDL.GetByDepID(objDepartment_DL.GetByDepType("RPD").DepID);
                cmbInstructedBy.DataSource = objEmployeeDL.Get_By_RoleType(EmployeeRole.RoleType.Manager.ToString(), true);
                cmbSupervisedBy.DataSource = objEmployeeDL.Get_By_RoleType(EmployeeRole.RoleType.Staff.ToString(), true);
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while loading New RPD Batch Activity", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 21
0
 private void gvMaterials_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Enter)
     {
         try
         {
             Material_DL objMatDL = new Material_DL(ConnectionStringClass.GetConnection());
             Material = objMatDL.Get(gvMaterials.SelectedRows[0].Cells["Column1"].Value.ToString());
             this.Close();
         }
         catch (Exception)
         {
             MessageBox.Show(this, "Error Occured", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
Exemplo n.º 22
0
        private void Load_LPStock()
        {
            try
            {
                DataTable dt        = new DataTable();
                GRN_DL    objGRN_DL = new GRN_DL(ConnectionStringClass.GetConnection());



                dgvGRN_LP.AutoGenerateColumns = false;
                objSourceLPStock.DataSource   = dt;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 23
0
        public long GenerateMR(PRPDBatch objPRPD)
        {
            MR objMR = new MR();
            MRMaterialCollec      objMRMatCollec           = new MRMaterialCollec();
            MRFinishProductCollec objMRFinishProductCollec = new MRFinishProductCollec();
            MRBasicProductCollec  objMRBasicProductCollec  = new MRBasicProductCollec();
            BatchMR       objBatchMR      = new BatchMR();
            Department_DL objDepDL        = new Department_DL(ConnectionStringClass.GetConnection());
            MR_DL         objMRDL         = new MR_DL(ConnectionStringClass.GetConnection());
            MRMaterial_DL objMRMaterialDL = new MRMaterial_DL(ConnectionStringClass.GetConnection());
            Store_DL      objStoreDL      = new Store_DL(ConnectionStringClass.GetConnection());

            try
            {
                objMR.MRDate           = DateTime.Now;
                objMR.MRDepartmentFrom = objDepDL.GetByDepType("PRPD");
                objMR.MREnterdBy       = CurrentUser.EmployeeID;
                objMR.MRStatus         = MR.Status.Initial;

                objMR.MRStore    = objStore;
                objMR.MRType     = MR.Type.Material;
                objMR.MRRemarks  = "Material Requition(Materials) for PRPD Batch NO " + objPRPD.PRPDBatchID.ToString();
                objMR.OriginType = MR.Origin.ToBatch;

                MRMaterial obj = new MRMaterial();
                obj.Description = "PRPD Batch Material Requition";
                obj.Material    = objPRPD.PRPDBatchMaterial;
                obj.MRBINNo     = "";
                obj.ReqdQty     = objPRPD.PRPDBatchQty;


                long MRNO = objMRDL.Add_M(objMR);
                if (MRNO > 0)
                {
                    objMR.MRNO = MRNO;
                    obj.MR     = objMR;
                    objMRMaterialDL.Add(obj);
                }
                return(MRNO);
            }
            catch (Exception ex)
            {
                return(0);
            }
        }
Exemplo n.º 24
0
        private void Load_WIP_Stock()
        {
            try
            {
                BatchPackingMR_DL objBatchPackingMR_DL = new BatchPackingMR_DL(ConnectionStringClass.GetConnection());

                dtWIPStock = objBatchPackingMR_DL.GetData_WIP(Convert.ToInt32(cmbSections.SelectedValue));

                dgvWIPStock.AutoGenerateColumns = false;
                objSourceWIPStock.DataSource    = dtWIPStock;
                dgvWIPStock.DataSource          = objSourceWIPStock;
                objSourceWIPStock.ResetBindings(true);
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while loading Activity List", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 25
0
        private void btnSaveDep_Click(object sender, EventArgs e)
        {
            try
            {
                Section_DL       objSection_DL       = new Section_DL(ConnectionStringClass.GetConnection());
                Department_DL    objDepDL            = new Department_DL(ConnectionStringClass.GetConnection());
                OverheadRates    objOverheadRates    = new OverheadRates();
                OverheadRates_DL objOverheadRates_DL = new OverheadRates_DL(ConnectionStringClass.GetConnection());
                Employee_DL      objEmpDL            = new Employee_DL(ConnectionStringClass.GetConnection());
                if (objSelectedSections.DepID != 0)
                {
                    Sections objSections = objSelectedSections;

                    if (textBox1.Text != "")
                    {
                        if (objSections.DepID != 0)
                        {
                            objOverheadRates.SectionID  = objSections.SectionID;
                            objOverheadRates.EnterdBy   = CurrentUser.EmployeeID;
                            objOverheadRates.EnterdDate = DateTime.Now;
                            objOverheadRates.Rate       = Convert.ToDecimal(textBox1.Text);

                            objOverheadRates_DL.Add(objOverheadRates);


                            ClearDep();
                            bindDepartment.DataSource = objSection_DL.GetDataView();
                        }
                    }
                    else
                    {
                        MessageBox.Show(this, "Please enter a valid Overhead Rate", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                else
                {
                    MessageBox.Show(this, "Please Select a Department from the list", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while saving overhead rate", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 26
0
        private void cmbActivityID_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                Machine_DL objMachineDL = new Machine_DL(ConnectionStringClass.GetConnection());
                if (cmbActivityID.SelectedItem != null)
                {
                    dtActivityMachine     = objMachineActivity_DL.GetDataByAct(Convert.ToInt64(cmbActivityID.SelectedValue));
                    cmbMachine.DataSource = dtActivityMachine;

                    cmbMachine.ValueMember   = "MachineID";
                    cmbMachine.DisplayMember = "MachineName";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
        }
Exemplo n.º 27
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (objRPDBatch != null)
                {
                    DialogResult dr = MessageBox.Show(this, "Are you sure you want to delete Selected RPD batch?\n\nClick Yes to delete", "Confirm Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                    if (dr == DialogResult.Yes)
                    {
                        MR_DL objMRDL = new MR_DL(ConnectionStringClass.GetConnection());
                        if (objRPDBatch.RPDBatchMR.MRStatus == MR.Status.Initial || objRPDBatch.RPDBatchMR.MRStatus == MR.Status.Reject)
                        {
                            if (objRPDBatch.RPDBatchMR.MRStatus == MR.Status.Initial)
                            {
                                objMRDL.Delete(objRPDBatch.RPDBatchMR.MRNO);
                            }

                            int res = objRPDBatchDL.Delete(objRPDBatch.RPDBatchID);

                            if (res > 0)
                            {
                                bindRPDBatch.DataSource = objRPDBatchDL.GetDataViewByState(Status, true);
                                ClearForm();
                                objRPDBatch = null;
                            }
                        }
                        else
                        {
                            MessageBox.Show(this, "Material Requsition In Prograss, You can't delete this RPD Batch File\nReject the Material Requsition and Try again.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        }
                    }
                }
                else
                {
                    MessageBox.Show(this, "Please select the RPD Batch file you want to delete", "Empty Selection", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Error occured while deleting", "Error", MessageBoxButtons.OK, MessageBoxIcon.Question);
            }
        }
Exemplo n.º 28
0
        private void btnApprove_Click(object sender, EventArgs e)
        {
            try
            {
                MainActivity_DL objMainActivity_DL = new MainActivity_DL(ConnectionStringClass.GetConnection());
                DialogResult    dr = MessageBox.Show(this, "Do you want to Approve Selected Batch?\n\nClick Yes to Approve", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (dr == DialogResult.Yes)
                {
                    objBatch.BatchApprovedBy = CurrentUser.UserEmp;
                    objBatch.BatchStatus     = Batch.Status.Approved;
                    int x = objBatchDL.Update_Approve(objBatch);
                    if (x > 0)
                    {
                        BatchActivity objWeigh   = new BatchActivity();
                        MainActivity  objMainAct = objMainActivity_DL.GetByName("Weighing");
                        objWeigh.Batch             = objBatch;
                        objWeigh.BatchActStatus    = BatchActivity.Status.Initial;
                        objWeigh.BlockNextActivity = false;
                        objWeigh.SequenceNo        = -1;
                        objWeigh.Part         = "N/A";
                        objWeigh.MainActivity = objMainAct;
                        objWeigh.LastEdited   = DateTime.Now;
                        objWeigh.ActType      = "Manufacturing";
                        objWeigh.ActMethod    = "Normal";

                        objBatchActivity_DL.Add(objWeigh);


                        Clear();

                        LoadBatches(Batch.Status.Initial);

                        objBatch = new Batch();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 29
0
        private void btnSet_Click(object sender, EventArgs e)
        {
            StockHoldingRate_DL objStockHoldingRateDL = new StockHoldingRate_DL(ConnectionStringClass.GetConnection());
            Employee_DL         objEmpDL = new Employee_DL(ConnectionStringClass.GetConnection());

            try
            {
                if (!txtNewRate.Text.Equals(""))
                {
                    DialogResult dr = MessageBox.Show(this, "Are you sure you want to change current Stock Holding Rate?\nChanging the rate cannot be Undo, Click Yes to continue, No to cancel", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
                    if (dr == DialogResult.Yes)
                    {
                        StockHoldingRate objNewStockHoldingRate = new StockHoldingRate();
                        objNewStockHoldingRate.Cost      = Convert.ToDecimal(txtNewRate.Text);
                        objNewStockHoldingRate.ChangedBy = CurrentUser.EmployeeID;
                        objNewStockHoldingRate.FromDate  = DateTime.Now;
                        objNewStockHoldingRate.ToDate    = DateTime.Now;
                        objStockHoldingRateDL.Add(objNewStockHoldingRate);

                        StockHoldingRate obj = new StockHoldingRate();
                        obj = objStockHoldingRateDL.GetFinal();
                        Employee objChangedBy = objEmpDL.Get(obj.ChangedBy);
                        txtEnterdBy.Text            = objChangedBy.EmployeeName;
                        txtEnterdDate.Text          = obj.FromDate.Value.ToShortDateString();
                        txtCurrentRate.Text         = obj.Cost.ToString();
                        bindStockHolding.DataSource = objStockHoldingRateDL.Get();

                        gvStockHoldingRates.CurrentCell = gvStockHoldingRates[1, gvStockHoldingRates.Rows.Count - 1];
                        gvStockHoldingRates.FirstDisplayedScrollingRowIndex = gvStockHoldingRates.Rows.Count - 1;
                    }
                }
                else
                {
                    MessageBox.Show(this, "Please enter a value as a New Rate", "Empty Fields", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 30
0
        private void frmPRPDMachine_Load(object sender, EventArgs e)
        {
            try
            {
                if (objPRPDBatchActivityDetails != null)
                {
                    MainActivity_DL objMainActivityDL = new MainActivity_DL(ConnectionStringClass.GetConnection());
                    MainActivity    obj = objMainActivityDL.Get(objPRPDBatchActivityDetails.PRPDBatchActivity.MainActID);
                    lblActivity.Text        = obj.MainActivityTitle;
                    txtID.Text              = objPRPDBatchActivityDetails.PRPDBatchActDetailsID.ToString();
                    txtComments.Text        = objPRPDBatchActivityDetails.Remarks;
                    bindMachines.DataSource = objPRPDActivityDetailsMachineDL.GetDataView(objPRPDBatchActivityDetails.PRPDBatchActDetailsID);

                    cmbMachine.DataSource = objMachineDL.GetDataView_By_Activity(objPRPDBatchActivityDetails.PRPDBatchActivity.MainActID);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, "Error occured while loading machine details", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 31
0
        private Boolean CheckIf_Atleast_OneApp_Exists()
        {
            Boolean exists = false;

            try
            {
                ConnectionStringClass connStr = new ConnectionStringClass();

                using (MySqlConnection conn = new MySqlConnection(connStr.ConnStr2))
                using (MySqlCommand cmd = new MySqlCommand("checkIfAtLeastOneAppExists", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    conn.Open();
                    using (MySqlDataReader rdr = cmd.ExecuteReader())
                    {
                        if (rdr.HasRows)
                            exists = true;
                        else
                            exists = false;
                    }
                }
                return exists;
            }
            catch (MySqlException mysqlEx)
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "MysqlException Error (Check if app exists): " + mysqlEx.Message;
            }
            catch (Exception Ex)
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "General Exception Error (Check if app exists): " + Ex.Message;
            }
            return exists;
        }
Exemplo n.º 32
0
        private void LoadApplicationsToGridView()
        {
            DataTable dTable = new DataTable();
            try
            {
                ConnectionStringClass connStr = new ConnectionStringClass();

                using (MySqlConnection conn = new MySqlConnection(connStr.ConnStr2))
                using (MySqlCommand cmd = new MySqlCommand("LoadApplicationsToGridView", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    using (MySqlDataAdapter dAdapter = new MySqlDataAdapter())
                    {
                        dAdapter.SelectCommand = cmd;
                        conn.Open();
                        dAdapter.Fill(dTable);
                        //Cache["DataTableApp"] = dTable;
                        Session["DataTableGV"] = dTable;
                        gvApplications.DataSource = (DataTable)this.Session["DataTableGV"];
                        gvApplications.DataBind();
                    }
                }
            }
            catch (MySqlException mysqlEx)
            {
                lblSecretaryError.Visible = true;
                lblSecretaryError.Text = "Bind gridview Applications Error: " + mysqlEx.Message;
            }
            catch (NullReferenceException nullRefEx)
            {
                lblSecretaryError.Visible = true;
                lblSecretaryError.Text = "Null Reference (gridview) Error: " + nullRefEx.Message;
            }
            catch (Exception Ex)
            {
                lblSecretaryError.Visible = true;
                lblSecretaryError.Text = "General gridview binding Error: " + Ex.Message;
            }
        }
Exemplo n.º 33
0
        private void SavePreReq()
        {
            try
            {
                //PC
                if (lbPC.Items.Count > 0)
                {
                    foreach (ListItem item in lbPC.Items)
                    {
                        ConnectionStringClass connStr = new ConnectionStringClass();

                        using (MySqlConnection conn = new MySqlConnection(connStr.ConnStr2))
                        using (MySqlCommand cmd = new MySqlCommand("setAppPreReq", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add(new MySqlParameter("@appId", Convert.ToInt32(lblApplicationIdNumber.Text)));
                            //cmd.Parameters.Add(new MySqlParameter("@appId", 3));    //temp app id num = 3
                            cmd.Parameters.Add(new MySqlParameter("@PReqId", item.Value));
                            cmd.Parameters.Add(new MySqlParameter("@PReqStatusId", 1));  //1 = PC

                            conn.Open();
                            //cmd.ExecuteNonQuery();
                            if (cmd.ExecuteNonQuery() < 1)
                            {
                                lblPreReqErrors.Visible = true;
                                lblPreReqErrors.Text = "stored procedure error when saving pre-requisite PC";
                            }
                        }
                    }
                }
                //PT
                if (lbPT.Items.Count > 0)
                {
                    foreach (ListItem item in lbPT.Items)
                    {
                        ConnectionStringClass connStr = new ConnectionStringClass();

                        using (MySqlConnection conn = new MySqlConnection(connStr.ConnStr2))
                        using (MySqlCommand cmd = new MySqlCommand("setAppPreReq", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add(new MySqlParameter("@appId", Convert.ToInt32(lblApplicationIdNumber.Text)));
                            //cmd.Parameters.Add(new MySqlParameter("@appId", 3));    //temp app id num = 3
                            cmd.Parameters.Add(new MySqlParameter("@PReqId", item.Value));
                            cmd.Parameters.Add(new MySqlParameter("@PReqStatusId", 2));  //2 = PT

                            conn.Open();
                            if (cmd.ExecuteNonQuery() < 1)
                            {
                                lblPreReqErrors.Visible = true;
                                lblPreReqErrors.Text = "stored procedure error when saving pre-requisite PC";
                            }
                        }
                    }
                }
                //RQ
                if (lbRQ.Items.Count > 0)
                {
                    foreach (ListItem item in lbRQ.Items)
                    {
                        ConnectionStringClass connStr = new ConnectionStringClass();

                        using (MySqlConnection conn = new MySqlConnection(connStr.ConnStr2))
                        using (MySqlCommand cmd = new MySqlCommand("setAppPreReq", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add(new MySqlParameter("@appId", Convert.ToInt32(lblApplicationIdNumber.Text)));
                            //cmd.Parameters.Add(new MySqlParameter("@appId", 3));    //temp app id num = 3
                            cmd.Parameters.Add(new MySqlParameter("@PReqId", item.Value));
                            cmd.Parameters.Add(new MySqlParameter("@PReqStatusId", 3));  //3 = RQ

                            conn.Open();
                            if (cmd.ExecuteNonQuery() < 1)
                            {
                                lblPreReqErrors.Visible = true;
                                lblPreReqErrors.Text = "stored procedure error when saving pre-requisite PC";
                            }
                        }
                    }
                }
                //NN
                if (lbNN.Items.Count > 0)
                {
                    foreach (ListItem item in lbNN.Items)
                    {
                        ConnectionStringClass connStr = new ConnectionStringClass();

                        using (MySqlConnection conn = new MySqlConnection(connStr.ConnStr2))
                        using (MySqlCommand cmd = new MySqlCommand("setAppPreReq", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add(new MySqlParameter("@appId", Convert.ToInt32(lblApplicationIdNumber.Text)));
                            //cmd.Parameters.Add(new MySqlParameter("@appId", 3));    //temp app id num = 3
                            cmd.Parameters.Add(new MySqlParameter("@PReqId", item.Value));
                            cmd.Parameters.Add(new MySqlParameter("@PReqStatusId", 4));  //4 = NN

                            conn.Open();
                            if (cmd.ExecuteNonQuery() < 1)
                            {
                                lblPreReqErrors.Visible = true;
                                lblPreReqErrors.Text = "stored procedure error when saving pre-requisite PC";
                            }
                        }
                    }
                }
                //RE
                if (lbRE.Items.Count > 0)
                {
                    foreach (ListItem item in lbRE.Items)
                    {
                        ConnectionStringClass connStr = new ConnectionStringClass();

                        using (MySqlConnection conn = new MySqlConnection(connStr.ConnStr2))
                        using (MySqlCommand cmd = new MySqlCommand("setAppPreReq", conn))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
                            cmd.Parameters.Add(new MySqlParameter("@appId", Convert.ToInt32(lblApplicationIdNumber.Text)));
                            //cmd.Parameters.Add(new MySqlParameter("@appId", 3));    //temp app id num = 3
                            cmd.Parameters.Add(new MySqlParameter("@PReqId", item.Value));
                            cmd.Parameters.Add(new MySqlParameter("@PReqStatusId", 5));  //5 = RE

                            conn.Open();
                            if (cmd.ExecuteNonQuery() < 1)
                            {
                                lblPreReqErrors.Visible = true;
                                lblPreReqErrors.Text = "stored procedure error when saving pre-requisite PC";
                            }
                        }
                    }
                }
            }
            catch
            { throw; }
        }
Exemplo n.º 34
0
        //test: bind data source MySQL to server control ListView (comments section)
        ////protected void BindDataListView()
        ////{
        ////    try                     //THIS IS USING CONNECTIONG STRING 1 (TEST DB), SP IS STORED IN THAT DB
        ////    {
        ////        ConnectionStringClass connStrings = new ConnectionStringClass();
        ////        List<Application> listOfAppObj = new List<Application>();
        ////        using (MySqlConnection conn = new MySqlConnection(connStrings.ConnStr1))
        ////        using (MySqlCommand cmd = new MySqlCommand("GetTestListView", conn))
        ////        {
        ////            cmd.CommandType = CommandType.StoredProcedure;
        ////            conn.Open();
        ////            using (MySqlDataReader rdr = cmd.ExecuteReader())
        ////            {
        ////                Application appObj;
        ////                while (rdr.Read())
        ////                {
        ////                    appObj = new Application();
        ////                    appObj.CommentId = Convert.ToInt32(rdr["id"].ToString());
        ////                    appObj.CommentBody = rdr["commentBody"].ToString();
        ////                    listOfAppObj.Add(appObj);
        ////                }
        ////            }
        ////        }
        ////        lvComment.DataSource = listOfAppObj;
        ////        lvComment.DataBind();
        ////    }
        ////    catch (NullReferenceException nullRefEx)
        ////    {
        ////        lblErrorApplicationForm.Text = "Error bindDataListView: (" + nullRefEx.Message + ")";
        ////    }
        ////    catch (MySqlException mysqlEx)
        ////    {
        ////        lblErrorApplicationForm.Text = "Error bindDataListView: (" + mysqlEx.Message + ")";
        ////    }
        ////    catch (Exception ex)
        ////    {
        ////        lblErrorApplicationForm.Text = "Error bindDataListView: General error (" + ex.Message + ")";
        ////    }
        ////}
        protected void PopulateDDLProgram()
        {
            ddlProgram.Items.Insert(0, "----SELECT ONE----");
            try
            {
                ConnectionStringClass connStrings = new ConnectionStringClass();

                using (MySqlConnection conn = new MySqlConnection(connStrings.ConnStr2))
                using (MySqlCommand cmd = new MySqlCommand("getDDLProgram", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    conn.Open();

                    using (MySqlDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                        {                                        //text(programName),    value(programId)
                            ddlProgram.Items.Add(new ListItem(rdr["Name"].ToString(), rdr["Id"].ToString()));
                        }
                    }
                }
            }
            catch (MySqlException mysqlEx)
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "Error bindDDLProgram: (" + mysqlEx.Message + ")";
            }
            catch (NullReferenceException nullRefEx)
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "Error bindDDLProgram: (" + nullRefEx.Message + ") , not connected to db";
            }
            catch (Exception ex)
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "Error bindDDLProgram: General error (" + ex.Message + ")";
            }
        }
Exemplo n.º 35
0
        protected void ddlProgram_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Clear all 5 listboxes (PC, PT, RQ, NN, RE)
            lbPC.Items.Clear();
            lbPT.Items.Clear();
            lbRQ.Items.Clear();
            lbNN.Items.Clear();
            lbRE.Items.Clear();

            if (ddlProgram.SelectedItem.Text.Contains("SELECT ONE"))
            { lbPreRequiredCourses.Items.Clear(); }

            else if (!ddlProgram.SelectedItem.Text.Contains("SELECT ONE"))
            {
                try
                {
                    lbPreRequiredCourses.Items.Clear();
                    ConnectionStringClass connString = new ConnectionStringClass();

                    using (MySqlConnection conn = new MySqlConnection(connString.ConnStr2))
                    using (MySqlCommand cmd = new MySqlCommand("getPrerequisiteCourses", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new MySqlParameter("@progid", ddlProgram.SelectedValue));
                        conn.Open();

                        using (MySqlDataReader rdr = cmd.ExecuteReader())
                        {
                            //List<String> listOfString = new List<String>();
                            while (rdr.Read())
                            {
                                lbPreRequiredCourses.Items.Add(new ListItem(rdr["pre-requisite"].ToString(),
                                                                            rdr["Id"].ToString()));
                            }
                        }
                        //txtFirstName.Text = ddlProgram.SelectedValue;
                    }
                }
                catch (MySqlException mysqlEx)
                {
                    lblAppDetailsErrors.Visible = true;
                    lblAppDetailsErrors.Text = "Error ddlProgram_SelectedIndexChanged: (" + mysqlEx.Message + ")";
                }
                catch (NullReferenceException nullRefEx)
                {
                    lblAppDetailsErrors.Visible = true;
                    lblAppDetailsErrors.Text = "Error ddlProgram_SelectedIndexChanged: (" + nullRefEx.Message + ")";
                }
                catch (Exception ex)
                {
                    lblAppDetailsErrors.Visible = true;
                    lblAppDetailsErrors.Text = "Error ddlProgram_SelectedIndexChanged: General error (" + ex.Message + ")";
                }
            }//END ELSE IF
        }
Exemplo n.º 36
0
        //
        //create new application must use this ID (returns MAX Id + 1)
        //
        private Int32 SetNewApplicationId()
        {
            Int32 newAppId = 0;
            try
            {
                ConnectionStringClass connStr = new ConnectionStringClass();

                using (MySqlConnection conn = new MySqlConnection(connStr.ConnStr2))
                using (MySqlCommand cmd = new MySqlCommand("getNewApplicationId", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    conn.Open();
                    using (MySqlDataReader rdr = cmd.ExecuteReader())
                    {
                        while (rdr.Read())
                            newAppId = Convert.ToInt32(rdr["maxId"]);
                    }
                }
                return newAppId + 1;
            }
            catch (MySqlException mysqlEx)
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "MysqlException Error (SetNewApplicationId()): " + mysqlEx.Message;
            }
            catch (Exception Ex)
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "General Error (SetNewApplicationId()): " + Ex.Message;
            }
            return newAppId;
        }
Exemplo n.º 37
0
        private void SaveButtonsTopBottom()
        {
            //txtFirstName.Text = DateTime.Today.ToString("yyyy-MM-dd");

            lblAppDetailsErrors.Text = String.Empty;
            lblAppDetailsErrors.Visible = false;

            //datetime.tryparse() -> returns true if parse is successful. False otherwise
            DateTime dt;
            if (String.IsNullOrEmpty(txtDateSubmitted.Text) ||
                     String.IsNullOrEmpty(txtFirstName.Text) ||
                     String.IsNullOrEmpty(txtLastName.Text) ||
                     String.IsNullOrEmpty(txtYear.Text))
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "Date submitted, first and last name, and year are required fields";
            }

            else if (!DateTime.TryParse(txtDateSubmitted.Text, out dt))
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "The correct date format is mm-dd-yyyy";
            }

            else if (!Regex.IsMatch(txtFirstName.Text, "[-'a-zA-Z]"))
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "First Name can only be letters";
            }

            else if (!Regex.IsMatch(txtLastName.Text, "[-'a-zA-Z]"))
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "Last name can only be letters";
            }

            else if (!Regex.IsMatch(txtYear.Text, "^[0-9]+$"))
            {
                lblAppDetailsErrors.Visible = true;
                lblAppDetailsErrors.Text = "Year has to be numbers";
            }

            else if (lbPC.Items.Count < 1 &&
                     lbPT.Items.Count < 1 &&
                     lbRQ.Items.Count < 1 &&
                     lbNN.Items.Count < 1 &&
                     lbRE.Items.Count < 1)
            {
                lblPreReqErrors.Visible = true;
                lblPreReqErrors.Text = "Prerequisite boxes cannot all be empty";
            }

            else
            {
                lblAppDetailsErrors.Text = String.Empty;
                lblAppDetailsErrors.Visible = false;
                lblPreReqErrors.Text = String.Empty;
                lblPreReqErrors.Visible = false;

                DateTime lastReviewedDate = LastViewedDate();

                try
                {
                    ConnectionStringClass connString = new ConnectionStringClass();

                    using (MySqlConnection conn = new MySqlConnection(connString.ConnStr2))
                    using (MySqlCommand cmd = new MySqlCommand("setApplication", conn))     //change SP to 'saveApplication'?
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add(new MySqlParameter("@firstN", txtFirstName.Text));
                        cmd.Parameters.Add(new MySqlParameter("@lastN", txtLastName.Text));
                        cmd.Parameters.Add(new MySqlParameter("@progId", ddlProgram.SelectedValue));
                        cmd.Parameters.Add(new MySqlParameter("@term", ddlTerm.SelectedValue));
                        cmd.Parameters.Add(new MySqlParameter("@year", Convert.ToInt32(txtYear.Text)));
                        //convert dateSubmitted to 'yyyy/dd/MM' format
                        cmd.Parameters.Add(new MySqlParameter("@dateInput", DateTime.Parse(txtDateSubmitted.Text).ToString("yyyy-MM-dd")));
                        cmd.Parameters.Add(new MySqlParameter("@app_Date", DateTime.Today.ToString("yyyy-MM-dd")));
                        cmd.Parameters.Add(new MySqlParameter("@lastViewed", DateTime.Today.ToString("yyyy-MM-dd")));
                        if (rbUndecided.Checked)
                            cmd.Parameters.Add(new MySqlParameter("@isAccept", "0"));
                        else if (rbAccepted.Checked)
                            cmd.Parameters.Add(new MySqlParameter("@isAccept", 2));
                        else if (rbDenied.Checked)
                            cmd.Parameters.Add(new MySqlParameter("@isAccept", 1));   //integer 0 is considered null in mysql
                        if (rbFinalizedYes.Checked)
                            cmd.Parameters.Add(new MySqlParameter("@isFinal", 2));
                        else if (rbFinalizedNo.Checked)
                            cmd.Parameters.Add(new MySqlParameter("@isFinal", 1));

                        //checking second section (listboxes)
                        //if(lbPC.Items.Count > 0)

                        conn.Open();
                        Int32 execNonQueryResult = cmd.ExecuteNonQuery();
                        if (execNonQueryResult < 1)
                        {
                            lblAppDetailsErrors.Visible = true;
                            lblAppDetailsErrors.Text = "stored procedure error when saving application";
                        }
                        else if (execNonQueryResult > 0)
                            SavePreReq();
                    }
                    Response.Redirect("ApplicationForm.aspx");
                }//End try

                catch (MySqlException mysqlEx)
                {
                    lblAppDetailsErrors.Visible = true;
                    lblAppDetailsErrors.Text = "Error saveButtonsTopBottom: (" + mysqlEx.Message + ")";
                }
                catch (InvalidCastException invCastEx)
                {
                    lblAppDetailsErrors.Visible = true;
                    lblAppDetailsErrors.Text = "Error saveButtonsTopBottom: (" + invCastEx.Message + ")";
                }
                catch (NullReferenceException nullRefEx)
                {
                    lblAppDetailsErrors.Visible = true;
                    lblAppDetailsErrors.Text = "Error saveButtonsTopBottom: (" + nullRefEx.Message + ")";
                }
                catch (Exception ex)
                {
                    lblAppDetailsErrors.Visible = true;
                    lblAppDetailsErrors.Text = "Error saveButtonsTopBottom: General error (" + ex.Message + ")";
                }
            }
        }