Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["username"] == null)
            {
                Response.Redirect("Default.aspx");
            }
            //user id is storing in session, if session in null or time out it will redirect to the Default.aspx.
            if (Context.Session != null)
            {
                if (Session.IsNewSession)
                {
                    HttpCookie newSessionIdCookie = Request.Cookies["ASP.NET_SessionId"];
                    if (newSessionIdCookie != null)
                    {
                        string newSessionIdCookieValue = newSessionIdCookie.Value;
                        if (newSessionIdCookieValue != string.Empty)
                        {
                            Response.Redirect("Default.aspx");
                        }
                    }
                }
            }
            ScriptManager.RegisterStartupScript(Page, this.GetType(), "Key", "<script>MakeStaticHeader('" + gvIPInvoices.ClientID + "', 500, 1450 , 40 ,true); </script>", false);
            if (!IsPostBack)
            {
                //page load.  get invoice's which are not proccessed by QC team, once process completed data will not appear in the page  and diplayed in the grid
                GetAssignedInvoices();

                EmployeesUpdatePanel.Update();
                //UpdatePanel2.Update();
                CommentsUpdatePanel.Update();
            }

            if (this.gvIPInvoices.SelectedIndex > -1)
            {
                // Call UpdateRow on every postback
                this.gvIPInvoices.UpdateRow(this.gvIPInvoices.SelectedIndex, false);
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "Key", "<script>MakeStaticHeader('" + gvIPInvoices.ClientID + "', 500, 1450 , 40 ,true); </script>", false);
            }
        }
Example #2
0
        //grid rows updation.
        protected void gvIPInvoices_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridView _gridView = (GridView)sender;
            string   key       = "";
            string   value     = "";
            //string selectedText = "";
            Label lblStatus = (_gridView.Rows[e.RowIndex].FindControl("lblStatus") as Label);

            //if (lblStatus.Text == "QC_Comp" || lblStatus.Text == "IP_Inp" || lblStatus.Text == "IP_Issue" || lblStatus.Text == "Rework")
            //{
            //    return;
            //}
            string[] _columnKeys = new string[] { "select", "File", "Source", "Status", " Invoice#", "Notes", "Issue", "Completed", "IP Asg By", "IP Com By", "ErrorNo", "QC Asg By", "QC Com By", "Back To IP" };

            if (lblStatus.Text == "IP_Asg" || lblStatus.Text == "Rework")
            {
                return;
            }
            if (e.RowIndex > -1)
            {
                for (int i = _firstEditCellIndex; i < _gridView.Columns.Count; i++)
                {
                    if (i == 1)
                    {
                        continue;
                    }
                    if (i == 2)
                    {
                        continue;
                    }
                    if (i == 3)
                    {
                        continue;
                    }
                    if (i == 4 || i == 5 || i == 10 || i == 11 || i == 13 || i == 15)
                    {
                        continue;
                    }
                    if (i == 14)
                    {
                        if (Session["access"].ToString() == "4")
                        {
                            continue;
                        }
                    }
                    if (i == 7)
                    {
                        continue;
                    }
                    if (i == 8)
                    {
                        continue;
                    }
                    if (i == 9)
                    {
                        continue;
                    }


                    int     rowid           = Convert.ToInt32(_gridView.DataKeys[e.RowIndex].Value.ToString());
                    Control _displayControl = _gridView.Rows[e.RowIndex].Cells[i].Controls[1];
                    Control _editControl    = _gridView.Rows[e.RowIndex].Cells[i].Controls[3];
                    key = _columnKeys[i - _firstEditCellIndex];
                    if (_editControl.Visible)
                    {
                        if (_editControl is TextBox)
                        {
                            value = ((TextBox)_editControl).Text;
                        }
                        else if (_editControl is DropDownList)
                        {
                            // value = ((DropDownList)_editControl).SelectedValue;
                            value = ((DropDownList)_editControl).SelectedItem.Text;
                        }
                        if (((Label)_displayControl).Text != value)
                        {
                            if (i == 6)
                            {
                                oldInvoice = ((Label)_displayControl).Text;
                                newInvoice = ((TextBox)_editControl).Text;

                                if (value.Length <= 0)
                                {
                                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Enter Invoice No", "alert('Please enter valid invoice#')", true);

                                    return;
                                }
                                lblgvRowId.Text     = rowid.ToString();
                                lblgvInvoiceNo.Text = value;

                                string script = "$(document).ready(function () { $('[id*=btnHidden]').click(); });";
                                ClientScript.RegisterStartupScript(this.GetType(), "load", script, true);

                                //  dt = new DataTable();
                                //  dt = objEMS.getLineItem(rowid);
                                //  if (dt.Rows.Count > 0)
                                //  {
                                //      SqlConnection con = new SqlConnection("Data Source=" + dt.Rows[0]["C_DataSource"].ToString() + ";Initial Catalog=" + dt.Rows[0]["C_DataBase"].ToString() + ";User ID=" + dt.Rows[0]["C_UserId"].ToString() + ";Password="******"C_Password"].ToString() + ";");

                                //      SqlDataAdapter da = new SqlDataAdapter("SELECT INVOICE_NUM, ATTACHMENT_NAME FROM IM_INVOICE IM WITH (NOLOCK) LEFT JOIN IM_INVOICE_ATTACHMENT IMA WITH (NOLOCK) ON IM.INVOICE_RID = IMA.INVOICE_FK where Invoice_Num = '1189798'", con);

                                //      dt = new DataTable();

                                //      da.Fill(dt);

                                //      if (dt.Rows.Count > 0)
                                //      {
                                //          da = new SqlDataAdapter("SELECT IM.INVOICE_NUM, COUNT(INVOICE_LINE_ITEM_RID) AS LINE_ITEM_COUNT FROM IM_INVOICE IM WITH (NOLOCK) " +
                                //                                               "JOIN IM_INVOICE_INVENTORY INV WITH (NOLOCK) ON IM.INVOICE_RID = INV.INVOICE_FK " +
                                //                                              "JOIN IM_INVOICE_LINE_ITEM LIN WITH (NOLOCK) ON LIN.INVOICE_INV_FK = INV.INVOICE_INVENTORY_RID " +
                                //                                               "WHERE Invoice_Num = '1189798' " +
                                //                                         "GROUP BY IM.INVOICE_NUM", con);
                                //          DataTable dt3 = new DataTable();
                                //          da.Fill(dt3);

                                //          if (dt3.Rows.Count > 0)
                                //          {
                                //              result = objEMS.UpdateInvoiceNo(value, rowid.ToString());
                                //              //result = objEMS.UpdateStatus("QC_Idle", dt3.Rows[0]["LINE_ITEM_COUNT"].ToString(), Convert.ToString(rowid));
                                //              if (result == true)
                                //              {
                                //                  result = false;
                                //                  result = objEMS.UpdateLineItemCount(dt3.Rows[0]["LINE_ITEM_COUNT"].ToString(), rowid.ToString());
                                //                  if (result == true)
                                //                  {
                                //                      ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Invoice No Success", "alert('Invoice# updated Successfully')", true);
                                //                  }
                                //                  else
                                //                  {
                                //                      ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Invoice No Failure", "alert('Error occured while updating line item count.. Please try again')", true);
                                //                  }
                                //                  //GetAssignedInvoices();
                                //                  //result = false;
                                //              }
                                //              else
                                //              {
                                //                  ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Invoice No", "alert('Error occured while updating invoice#.. Please try again')", true);
                                //              }
                                //          }
                                //      }
                                //      else
                                //      {
                                //          ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "LineItem Error", "alert('OOPS! You missed to attach the invoice to EMS')", true);
                                //      }
                                //}
                            }
                            else if (i == 12)
                            {
                                bool result;
                                result = objEMS.UpdateErrorNo(value, rowid.ToString());
                                if (result == true)
                                {
                                    //RecordLog
                                    result = objEMS.RecordLog(rowid.ToString(), "QC", "Error No", ((Label)_displayControl).Text, value, Session["username"].ToString());
                                }
                                else
                                {
                                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Error No", "alert('Error occured.. Please try again')", true);
                                }
                            }
                            else if (i == 14)
                            {
                                bool result;
                                if (value == "--Select--")
                                {
                                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Select User", "alert('Please select user')", true);
                                }
                                else
                                {
                                    result = objEMS.QCAssign(rowid.ToString(), "QC_Asg", Session["username"].ToString(), value, DateTime.Now.ToString());
                                    if (result == true)
                                    {
                                        //RecordLog
                                        result = objEMS.RecordLog(rowid.ToString(), "QC", "QC_AsgTo", ((Label)_displayControl).Text, value, Session["username"].ToString());
                                        if (result == true)
                                        {
                                            result = false;
                                        }
                                    }
                                    else
                                    {
                                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Update User", "alert('Error occured while updating user.. Please try again')", true);
                                    }
                                }
                            }
                        }
                        e.NewValues.Add(key, value);
                        break;
                    }
                }
                _gridView.SelectedIndex = -1;
                //GetAssignedInvoices();
                //Namohar Changed code for Grid refresh on 10/02/2017
                if (search_textbox.Text == "")
                {
                    GetAssignedInvoices();
                }
                else
                {
                    if (ddlList.SelectedItem.Text == "ReceiveDate")
                    {
                        Flag = 1;
                    }
                    else
                    {
                        Flag = 0;
                    }
                    SerachData();
                }
                EmployeesUpdatePanel.Update();
                //UpdatePanel2.Update();
                // CommentsUpdatePanel.Update();
            }
        }
Example #3
0
        //grid records selecting
        protected void gvIPInvoices_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                LinkButton _singleClickButton = (LinkButton)e.Row.Cells[0].Controls[0];

                string _jsSingle = ClientScript.GetPostBackClientHyperlink(_singleClickButton, "");


                if (Page.Validators.Count > 0)
                {
                    _jsSingle = _jsSingle.Insert(11, "if(Page_ClientValidate())");
                }
                checked
                {
                    for (int columnIndex = _firstEditCellIndex; columnIndex < e.Row.Cells.Count; columnIndex++)
                    {
                        string js = _jsSingle.Insert(_jsSingle.Length - 2, columnIndex.ToString());
                        e.Row.Cells[columnIndex].Attributes["onclick"] = js;
                        e.Row.Cells[columnIndex].Attributes["style"]  += "cursor:pointer;cursor:hand;";
                    }
                }


                Label        lblStatus    = (Label)e.Row.FindControl("lblStatus");
                CheckBox     chkSelect    = (CheckBox)e.Row.FindControl("chkSelect");
                CheckBox     chkIssue     = (CheckBox)e.Row.FindControl("chkIssue");
                CheckBox     chkReturn    = (CheckBox)e.Row.FindControl("chkReturn");
                CheckBox     chkCompleted = (CheckBox)e.Row.FindControl("chkCompleted");
                DropDownList ddlGvUser    = (DropDownList)e.Row.FindControl("ddlGvUser");

                dt = new DataTable();
                dt = objEMS.getUser("QC");
                if (dt.Rows.Count > 0)
                {
                    ddlGvUser.DataSource     = dt;
                    ddlGvUser.DataTextField  = "UL_User_Name";
                    ddlGvUser.DataValueField = "UL_ID";
                    ddlGvUser.DataBind();
                }
                if (lblStatus.Text == "QC_Asg")
                {
                    chkSelect.Checked = false;
                }
                else if (lblStatus.Text == "QC_Idle")
                {
                    chkSelect.Checked = false;
                }
                else
                {
                    chkSelect.Checked = true;
                }
                if (lblStatus.Text == "QC_Issue")
                {
                    chkSelect.Checked = true;
                    chkIssue.Checked  = true;
                }
                if (lblStatus.Text == "Rework")
                {
                    chkSelect.Checked = true;
                    chkReturn.Checked = true;
                }

                if (lblStatus.Text == "QC_Comp")
                {
                    chkSelect.Checked    = true;
                    chkCompleted.Checked = true;
                }
                //if (lblStatus.Text == "QC_Idle" || lblStatus.Text == "QC_Asg" || lblStatus.Text == "QC_Inp" || lblStatus.Text == "QC_Issue" || lblStatus.Text == "QC_Comp")
                //{
                //    chkSelect.Checked = true;
                //    chkComp.Checked = true;
                //}
            }
            EmployeesUpdatePanel.Update();
            //UpdatePanel2.Update();
            CommentsUpdatePanel.Update();
        }