private void ListFilteredProductModels(int opt, string stockid) { try { grdList.Rows.Clear(); forwarderList = demDB.getForwarders(docID, Login.empLoggedIn); approverList = demDB.getApprovers(docID, Login.empLoggedIn); ProductModelsDB pmdb = new ProductModelsDB(); List <productmodels> PMList = pmdb.getFilteredModelName(userString, opt, stockid); if (opt == 1) { lblActionHeader.Text = "List of Action Pending Documents"; } else if (opt == 2) { lblActionHeader.Text = "List of In-Process Documents"; } else if (opt == 3 || opt == 6) { lblActionHeader.Text = "List of Approved Documents"; } foreach (productmodels pm in PMList) { if (opt == 1) { if (pm.DocumentStatus == 99) { continue; } } grdList.Rows.Add(); grdList.Rows[grdList.RowCount - 1].Cells["RowID"].Value = pm.rowID; grdList.Rows[grdList.RowCount - 1].Cells["ModelNo"].Value = pm.ModelNo; grdList.Rows[grdList.RowCount - 1].Cells["ModelName"].Value = pm.ModelName; grdList.Rows[grdList.RowCount - 1].Cells["StockItem"].Value = pm.StockItemID; grdList.Rows[grdList.RowCount - 1].Cells["StockItemName"].Value = pm.StockItemName; grdList.Rows[grdList.RowCount - 1].Cells["Remarks"].Value = pm.Remarks; grdList.Rows[grdList.RowCount - 1].Cells["gStatus"].Value = pm.Status; grdList.Rows[grdList.RowCount - 1].Cells["gCreateTime"].Value = pm.CreateTime; grdList.Rows[grdList.RowCount - 1].Cells["gCreateUser"].Value = pm.CreateUser; grdList.Rows[grdList.RowCount - 1].Cells["ForwardUser"].Value = pm.ForwardUser; grdList.Rows[grdList.RowCount - 1].Cells["ApproveUser"].Value = pm.ApproveUser; grdList.Rows[grdList.RowCount - 1].Cells["Creator"].Value = pm.CreatorName; grdList.Rows[grdList.RowCount - 1].Cells["Forwarder"].Value = pm.ForwarderName; grdList.Rows[grdList.RowCount - 1].Cells["Approver"].Value = pm.ApproverName; grdList.Rows[grdList.RowCount - 1].Cells["DocumentStatusNo"].Value = pm.DocumentStatus; grdList.Rows[grdList.RowCount - 1].Cells["Forwarders"].Value = pm.ForwarderList; } } catch (Exception ex) { MessageBox.Show("Error in Product Model Listing"); } setButtonVisibility("init"); pnlList.Visible = true; grdList.Columns["Creator"].Visible = true; grdList.Columns["Forwarder"].Visible = true; grdList.Columns["Approver"].Visible = true; }
private void showModelListView(string stockID) { //removeControlsFromModelPanel(); //lv = new ListView(); //lv.CheckBoxes = true; //lv.Items.Clear(); //pnlModel.BorderStyle = BorderStyle.FixedSingle; //pnlModel.Bounds = new Rectangle(new Point(100, 10), new Size(700, 300)); frmPopup = new Form(); frmPopup.StartPosition = FormStartPosition.CenterScreen; frmPopup.BackColor = Color.CadetBlue; frmPopup.MaximizeBox = false; frmPopup.MinimizeBox = false; frmPopup.ControlBox = false; frmPopup.FormBorderStyle = FormBorderStyle.FixedSingle; frmPopup.Size = new Size(450, 310); Label lbl = new Label(); lbl.AutoSize = true; lbl.Location = new Point(5, 5); lbl.Size = new Size(300, 20); lbl.Text = "ListView For Model"; lbl.Font = new Font("Serif", 10, FontStyle.Bold); lbl.ForeColor = Color.Green; frmPopup.Controls.Add(lbl); lv = ProductModelsDB.getModelsForProductListView(stockID.Substring(0, stockID.IndexOf('-'))); if (lv.Items.Count == 0) { txtModelNo.Text = "NA"; txtModelName.Text = "NA"; pnlModel.Visible = false; return; } lv.Bounds = new Rectangle(new Point(0, 25), new Size(450, 250)); //pnlModel.Controls.Remove(lv); frmPopup.Controls.Add(lv); Button lvOK = new Button(); lvOK.Text = "OK"; lvOK.BackColor = Color.Tan; lvOK.Location = new Point(40, 280); lvOK.Click += new System.EventHandler(this.lvOK_Click3); frmPopup.Controls.Add(lvOK); Button lvCancel = new Button(); lvCancel.Text = "CANCEL"; lvCancel.BackColor = Color.Tan; lvCancel.Location = new Point(130, 280); lvCancel.Click += new System.EventHandler(this.lvCancel_Click3); frmPopup.Controls.Add(lvCancel); frmPopup.ShowDialog(); //pnlModel.Visible = true; //pnlAddEdit.Controls.Add(pnlModel); //pnlAddEdit.BringToFront(); //pnlModel.BringToFront(); //pnlModel.Focus(); }
private void btnApprove_Click(object sender, EventArgs e) { try { ProductModelsDB pmdb = new ProductModelsDB(); DialogResult dialog = MessageBox.Show("Are you sure to Approve the document ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { string ModelNo = (Convert.ToInt32(pmdb.getLastModelNo(prevpmodel.StockItemID)) + 1).ToString(); if (pmdb.ApproveProductModel(prevpmodel, ModelNo)) { MessageBox.Show("Product Model Approved"); if (!updateDashBoard(prevpmodel, 2)) { MessageBox.Show("DashBoard Fail to update"); } closeAllPanels(); listOption = 1; ListFilteredProductModels(listOption, pid); setButtonVisibility("btnEditPanel"); //activites are same for cance, forward,approce and reverse } } } catch (Exception) { } }
private void lvForwardOK_Click(object sender, EventArgs e) { try { { int kount = 0; string approverUID = ""; string approverUName = ""; foreach (ListViewItem itemRow in lvApprover.Items) { if (itemRow.Checked) { approverUID = itemRow.SubItems[2].Text; approverUName = itemRow.SubItems[1].Text; kount++; } } if (kount == 0) { MessageBox.Show("Select one approver"); return; } if (kount > 1) { MessageBox.Show("Select only one approver"); return; } else { DialogResult dialog = MessageBox.Show("Are you sure to forward the document ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { //do forward activities ProductModelsDB pmdb = new ProductModelsDB(); prevpmodel.ForwardUser = approverUID; prevpmodel.ForwarderList = prevpmodel.ForwarderList + approverUName + Main.delimiter1 + approverUID + Main.delimiter1 + Main.delimiter2; if (pmdb.forwardProductModel(prevpmodel)) { frmPopup.Close(); frmPopup.Dispose(); MessageBox.Show("Document Forwarded"); if (!updateDashBoard(prevpmodel, 1)) { MessageBox.Show("DashBoard Fail to update"); } closeAllPanels(); listOption = 1; ListFilteredProductModels(listOption, pid); setButtonVisibility("btnEditPanel"); //activites are same for cance, forward,approce and reverse } } } } } catch (Exception) { } }
private void showModelListView(string stockID) { frmPopup = new Form(); frmPopup.StartPosition = FormStartPosition.CenterScreen; frmPopup.BackColor = Color.CadetBlue; frmPopup.MaximizeBox = false; frmPopup.MinimizeBox = false; frmPopup.ControlBox = false; frmPopup.FormBorderStyle = FormBorderStyle.FixedSingle; frmPopup.Size = new Size(550, 310); Label lbl = new Label(); lbl.AutoSize = true; lbl.Location = new Point(5, 5); lbl.Size = new Size(300, 20); lbl.Text = "ListView For Model"; lbl.Font = new Font("Serif", 10, FontStyle.Bold); lbl.ForeColor = Color.Black; frmPopup.Controls.Add(lbl); lv = ProductModelsDB.getModelsForProductListView(stockID); if (lv.Items.Count == 0) { txtModelNo.Text = "NA"; txtModelName.Text = "NA"; return; } lv.Bounds = new Rectangle(new System.Drawing.Point(0, 25), new Size(550, 250)); frmPopup.Controls.Add(lv); Button lvOK = new Button(); lvOK.Text = "OK"; lvOK.BackColor = Color.Tan; lvOK.Location = new System.Drawing.Point(40, 280); lvOK.Click += new System.EventHandler(this.lvOK_Click3); frmPopup.Controls.Add(lvOK); Button lvCancel = new Button(); lvCancel.Text = "CANCEL"; lvCancel.BackColor = Color.Tan; lvCancel.Location = new System.Drawing.Point(130, 280); lvCancel.Click += new System.EventHandler(this.lvCancel_Click1); frmPopup.Controls.Add(lvCancel); frmPopup.ShowDialog(); }
private void btnReverse_Click(object sender, EventArgs e) { try { DialogResult dialog = MessageBox.Show("Are you sure to Reverse the document ?", "Yes", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { string reverseStr = getReverseString(prevpmodel.ForwarderList); ProductModelsDB pmdb = new ProductModelsDB(); if (reverseStr.Trim().Length > 0) { int ind = reverseStr.IndexOf("!@#"); prevpmodel.ForwarderList = reverseStr.Substring(0, ind); prevpmodel.ForwardUser = reverseStr.Substring(ind + 3); prevpmodel.DocumentStatus = prevpmodel.DocumentStatus - 1; } else { prevpmodel.ForwarderList = ""; prevpmodel.ForwardUser = ""; prevpmodel.DocumentStatus = 1; } if (pmdb.reverseProductModel(prevpmodel)) { MessageBox.Show("Product Model Reversed"); closeAllPanels(); listOption = 1; ListFilteredProductModels(listOption, pid); setButtonVisibility("btnEditPanel"); //activites are same for cance, forward,approce and reverse } } } catch (Exception ex) { } }
private void btnSave_Click(object sender, EventArgs e) { Boolean status = true; try { ProductModelsDB pmdb = new ProductModelsDB(); productmodels pm = new productmodels(); System.Windows.Forms.Button btn = sender as System.Windows.Forms.Button; string btnText = btnSave.Text; try { pm.ModelName = txtModelName.Text; pm.StockItemID = txtStockItemID.Text.Substring(0, txtStockItemID.Text.IndexOf('-')); pm.Remarks = txtRemarks.Text; pm.ForwarderList = prevpmodel.ForwarderList; } catch (Exception ex) { MessageBox.Show("Validation failed"); return; } if (pmdb.validateProductModel(pm)) { if (btnText.Equals("Update")) { pm.DocumentStatus = prevpmodel.DocumentStatus; if (pmdb.updateProductModels(pm, prevpmodel)) { MessageBox.Show("Product Model Details updated"); closeAllPanels(); listOption = 1; ListFilteredProductModels(listOption, pid); } else { status = false; } if (!status) { MessageBox.Show("Failed to update Product Model"); } } else if (btnText.Equals("Save")) { pm.DocumentStatus = 1; if (pmdb.insertProductModel(pm)) { MessageBox.Show("Product Model Details Added"); closeAllPanels(); listOption = 1; ListFilteredProductModels(listOption, pid); } else { status = false; } if (!status) { MessageBox.Show("Failed to Insert Product Model"); } } } else { MessageBox.Show("Product Model Validation failed"); status = false; } } catch (Exception ex) { MessageBox.Show("Product Model(Save()) : Error"); status = false; } if (status) { setButtonVisibility("btnEditPanel"); //activites are same for cancel, forward,approve, reverse and save } }