Esempio n. 1
0
        private void ListFilteredmovementhistory()
        {
            try
            {
                grdList.Rows.Clear();
                MovementHistoryDB           mhdb   = new MovementHistoryDB();
                List <movementhistory>      MHList = new List <movementhistory>();
                Dictionary <String, String> dict   = new Dictionary <string, string>();
                string selEmp = "";
                if (txtEmpID.Text.Trim().Length != 0)
                {
                    selEmp = txtEmpID.Text.Substring(0, txtEmpID.Text.IndexOf('-'));
                }
                string selPurpose = "";
                if (cmbPurpose.SelectedIndex != -1)
                {
                    selPurpose = ((Structures.ComboBoxItem)cmbPurpose.SelectedItem).HiddenValue;
                }


                if (txtEmpID.Text.Trim().Length != 0)
                {
                    dict.Add("EmpId", selEmp);
                }
                else
                {
                    dict.Add("EmpId", "");
                }
                if (cmbPurpose.SelectedIndex != -1)
                {
                    dict.Add("Purpose", selPurpose);
                }
                else
                {
                    dict.Add("Purpose", "");
                }
                if (cmbDocStatus.SelectedIndex != -1)
                {
                    if (cmbDocStatus.SelectedItem.ToString() == "Canceled")
                    {
                        dict.Add("DocStat", "6,1,98");
                    }
                    else
                    {
                        dict.Add("DocStat", getStatus(cmbDocStatus.SelectedItem.ToString()).ToString());
                    }
                }

                else
                {
                    dict.Add("DocStat", "");
                }
                if (cmbDocStatus.SelectedIndex != -1)
                {
                    if (cmbDocStatus.SelectedItem.ToString().Equals("All"))
                    {
                        if (txtEmpID.Text.Length != 0 && cmbPurpose.SelectedIndex != -1)
                        {
                            MHList = mhdb.getMovementHistoryForAll(dtFromDate.Value, dtToDate.Value, selEmp, selPurpose);
                        }
                        else if (txtEmpID.Text.Length != 0)
                        {
                            MHList = mhdb.getMovementHistoryForAll(dtFromDate.Value, dtToDate.Value, selEmp, "");
                        }
                        else if (cmbPurpose.SelectedIndex != -1)
                        {
                            MHList = mhdb.getMovementHistoryForAll(dtFromDate.Value, dtToDate.Value, "", selPurpose);
                        }
                        else
                        {
                            MHList = mhdb.getMovementHistoryForAll(dtFromDate.Value, dtToDate.Value, "", "");
                        }
                    }
                    else
                    {
                        MHList = mhdb.getFilteredMovementHistory(dtFromDate.Value, dtToDate.Value, getOPtion(), dict);
                    }
                }
                else
                {
                    MHList = mhdb.getFilteredMovementHistory(dtFromDate.Value, dtToDate.Value, getOPtion(), dict);
                }

                //grdList.Columns["dt"].Visible = true;


                foreach (movementhistory mh in MHList)
                {
                    if (cmbDocStatus.SelectedIndex != 2 && cmbDocStatus.SelectedIndex != 0 && mh.documentstatus == 1 && mh.status == 1)
                    {
                        continue;
                    }
                    grdList.Rows.Add();
                    //grdList.Rows[grdList.RowCount - 1].Cells["mRowID"].Value = mh.rowid;
                    grdList.Rows[grdList.RowCount - 1].Cells["mDate"].Value          = mh.date;
                    grdList.Rows[grdList.RowCount - 1].Cells["mEmployee"].Value      = mh.empname;
                    grdList.Rows[grdList.RowCount - 1].Cells["mPurpose"].Value       = mh.purpose;
                    grdList.Rows[grdList.RowCount - 1].Cells["mExitTime"].Value      = mh.exittime;
                    grdList.Rows[grdList.RowCount - 1].Cells["mReturnTime"].Value    = mh.returntime;
                    grdList.Rows[grdList.RowCount - 1].Cells["aExitTime"].Value      = mh.actexittime;
                    grdList.Rows[grdList.RowCount - 1].Cells["aReturnTime"].Value    = mh.actreturntime;
                    grdList.Rows[grdList.RowCount - 1].Cells["MovementStatus"].Value = MovementRegisterDB.valuetostring(mh.documentstatus, mh.status);
                }
                if (grdList.Rows.Count != 0)
                {
                    btnExportToExcell.Visible = true;
                }
                else
                {
                    btnExportToExcell.Visible = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error in Movement History  Listing");
            }
            setButtonVisibility("init");
            pnlList.Visible = true;
        }