protected void gv_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType != DataControlRowType.DataRow)
     {
         return;
     }
     this.objProjectMasterDT = this.objProjectMasterBll.GetDataByProjectID(int.Parse(e.Row.Cells[0].Text));
     e.Row.Cells[0].Text     = this.objProjectMasterDT.Rows[0]["ProjectName"].ToString();
     this.objTaskMasterDT    = this.objTaskMasterBll.GetDataByTaskID(int.Parse(e.Row.Cells[1].Text));
     e.Row.Cells[1].Text     = this.objTaskMasterDT.Rows[0]["TaskName"].ToString();
 }
        private void ViewRecord(string sId)
        {
            bool flag = false;

            this.objProjectMasterDT = this.objProjectMasterBll.GetDataByProjectID(int.Parse(sId));
            if (this.objProjectMasterDT.Rows.Count > 0)
            {
                flag = this.objProjectMasterDT.Rows[0]["ClientID"].ToString() == this.hfClientID.Value;
            }
            if (this.objProjectMasterDT.Rows.Count > 0 && flag)
            {
                this.hfProjectID.Value      = this.objProjectMasterDT.Rows[0]["ProjectID"].ToString();
                this.lblProject.Text        = this.objProjectMasterDT.Rows[0]["ProjectName"].ToString();
                this.hfCompanyID.Value      = this.objProjectMasterDT.Rows[0]["CompanyID"].ToString();
                this.lblProjectManager.Text = this.objProjectMasterDT.Rows[0]["ProjectManager"].ToString();
                if (string.IsNullOrEmpty(this.lblProjectManager.Text))
                {
                    return;
                }
                int iStaffID = int.Parse(this.lblProjectManager.Text);
                if (iStaffID == 0)
                {
                    this.objCompanyMasterDT     = this.objCompanyMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
                    this.lblProjectManager.Text = this.objCompanyMasterDT.Rows[0]["CompanyContactPerson"].ToString();
                }
                else
                {
                    this.objStaffMasterDT = this.objStaffMasterBll.GetDataByStaffID(iStaffID);
                    if (this.objStaffMasterDT.Rows.Count <= 0)
                    {
                        return;
                    }
                    this.lblProjectManager.Text = (string)this.objStaffMasterDT.Rows[0]["FirstName"] + (object)" " + (string)this.objStaffMasterDT.Rows[0]["LastName"];
                }
            }
            else
            {
                this.pnlViewAll.Visible = true;
                this.pnlView.Visible    = false;
                this.BindGrid();
            }
        }
        private void ViewRecord(string iD)
        {
            this.objProjectMasterDT = this.objProjectMasterBll.GetDataByProjectID(int.Parse(iD));
            if (this.objProjectMasterDT.Rows.Count <= 0)
            {
                return;
            }
            this.hfProjectID.Value = this.objProjectMasterDT.Rows[0]["ProjectID"].ToString();
            this.aMethod.Attributes.Add("href", "ProjectMaster.aspx?cmd=add&ID=" + this.hfProjectID.Value);
            this.hfCompanyID.Value   = this.objProjectMasterDT.Rows[0]["CompanyID"].ToString();
            this.lblProjectName.Text = this.objProjectMasterDT.Rows[0]["ProjectName"].ToString();
            this.lblManager.Text     = this.objProjectMasterDT.Rows[0]["ProjectManager"].ToString();
            this.lblMethod.Text      = this.objProjectMasterDT.Rows[0]["BillingMethod"].ToString();
            string str1 = "<b>Estimate:</b> " + this.objProjectMasterDT.Rows[0]["TimeEstimate"] + " hrs<br />";
            string str2 = "width: 0;";

            this.lblProDetails.Text = str1 + "<b>Progress:</b> 0%";
            this.gvBudget.DataBind();
            if (this.gvBudget.Rows.Count > 0)
            {
                string text = this.gvBudget.Rows[0].Cells[3].Text;
                str2 = "width: " + text + "%;";
                this.lblProDetails.Text = str1 + "<b>Progress:</b> " + text + "%";
            }
            this.divPro.Attributes.Add("style", str2);
            if (this.lblManager.Text == "0")
            {
                this.objCompanyMasterDT = this.objCompanyMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value));
                this.lblManager.Text    = this.objCompanyMasterDT.Rows[0]["CompanyContactPerson"].ToString();
            }
            else
            {
                this.objStaffMasterDT = this.objStaffMasterBll.GetDataByStaffID(int.Parse(this.lblManager.Text));
                this.lblManager.Text  = (string)this.objStaffMasterDT.Rows[0]["FirstName"] + (object)" " + (string)this.objStaffMasterDT.Rows[0]["LastName"];
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            if (!this.Page.IsValid)
            {
                return;
            }
            if (this.txtProjectName.Text.Trim().Length > 0)
            {
                this.objProjectMasterDT = this.objProjectMasterBll.GetDataByProjectName(int.Parse(this.hfCompanyID.Value), this.txtProjectName.Text.Trim());
                if (this.objProjectMasterDT.Rows.Count > 0)
                {
                    this.checkInDB = true;
                    this.DisplayAlert("Project Already Exists..!");
                }
                if (this.checkInDB)
                {
                    return;
                }
                Decimal?dPackageRate = new Decimal?();
                Decimal?dFlatAmount  = new Decimal?();
                if (this.txtProjectRate.Text.Trim().Length > 0)
                {
                    dPackageRate = new Decimal?(Decimal.Parse(this.txtProjectRate.Text.Trim()));
                }
                if (this.txtFlatAmount.Text.Trim().Length > 0)
                {
                    dFlatAmount = new Decimal?(Decimal.Parse(this.txtFlatAmount.Text.Trim()));
                }
                int iProjectID = this.objProjectMasterBll.AddProject(int.Parse(this.hfCompanyID.Value), this.txtProjectName.Text.Trim(), this.txtProjectDesc.Text.Trim(), new int?(int.Parse(this.ddlClient.SelectedItem.Value)), this.chkCanClient.Checked, new int?(int.Parse(this.ddlManager.SelectedItem.Value)), this.ddlMethod.SelectedItem.Value, dPackageRate, dFlatAmount, new Decimal?(Decimal.Parse(this.txtTimeEstimate.Text.Trim())), true, false, false, false);
                if (iProjectID != 0)
                {
                    if (this.gvUsers.Rows.Count > 0)
                    {
                        for (int index = 0; index < this.gvUsers.Rows.Count; ++index)
                        {
                            CheckBox checkBox = (CheckBox)this.gvUsers.Rows[index].Cells[0].FindControl("chkUserID");
                            if (checkBox.Checked)
                            {
                                string cssClass = checkBox.CssClass;
                                string toolTip  = checkBox.ToolTip;
                                switch (cssClass)
                                {
                                case "Staff":
                                    this.objStaffProjectDetailBll.AddStaffProjectDetail(int.Parse(this.hfCompanyID.Value), int.Parse(toolTip), iProjectID);
                                    continue;

                                case "Contractor":
                                    this.objContractorProjectDetailBll.AddContractorProjectDetail(int.Parse(this.hfCompanyID.Value), int.Parse(toolTip), iProjectID);
                                    continue;

                                case "Admin":
                                    this.objProjectMasterBll.UpdateCompanyTeam(true, iProjectID);
                                    continue;

                                default:
                                    continue;
                                }
                            }
                        }
                    }
                    if (this.gvTask.Rows.Count > 0)
                    {
                        for (int index = 0; index < this.gvTask.Rows.Count; ++index)
                        {
                            CheckBox checkBox = (CheckBox)this.gvTask.Rows[index].Cells[0].FindControl("chkTaskID");
                            if (checkBox.Checked)
                            {
                                string toolTip = checkBox.ToolTip;
                                this.objProjectTaskDetailBll.AddProjectTaskDetail(int.Parse(this.hfCompanyID.Value), iProjectID, int.Parse(toolTip));
                            }
                        }
                    }
                    this.Session["saveProject"] = (object)1;
                    this.DisplayAlert("Project Successfully Added..!");
                    this.Response.Redirect("~/BillTransact/ProjectMaster.aspx?cmd=add&ID=" + (object)iProjectID);
                }
                else
                {
                    this.DisplayAlert("Some Error Occured Please Try After Sometime..!");
                }
            }
            else
            {
                this.DisplayAlert("Project Name Is Required");
            }
        }
        private void SetRecord(string iD)
        {
            this.objProjectMasterDT = this.objProjectMasterBll.GetDataByProjectID(int.Parse(iD));
            if (this.objProjectMasterDT.Rows.Count <= 0)
            {
                return;
            }
            this.hfProjectID.Value        = this.objProjectMasterDT.Rows[0]["ProjectID"].ToString();
            this.hfCompanyID.Value        = this.objProjectMasterDT.Rows[0]["CompanyID"].ToString();
            this.txtProjectName.Text      = this.objProjectMasterDT.Rows[0]["ProjectName"].ToString();
            this.txtProjectDesc.Text      = this.objProjectMasterDT.Rows[0]["ProjectDesc"].ToString();
            this.ddlManager.SelectedValue = this.objProjectMasterDT.Rows[0]["ProjectManager"].ToString();
            this.ddlClient.SelectedValue  = this.objProjectMasterDT.Rows[0]["ClientID"].ToString();
            this.chkCanClient.Visible     = this.objProjectMasterDT.Rows[0]["ClientID"].ToString() != "0";
            this.chkCanClient.Checked     = bool.Parse(this.objProjectMasterDT.Rows[0]["CanClient"].ToString());
            this.ddlMethod.SelectedIndex  = this.ddlMethod.Items.IndexOf(this.ddlMethod.Items.FindByText(this.objProjectMasterDT.Rows[0]["BillingMethod"].ToString()));
            this.ddlMethod_SelectedIndexChanged((object)null, (EventArgs)null);
            this.txtFlatAmount.Text   = this.objProjectMasterDT.Rows[0]["FlatAmount"].ToString();
            this.txtProjectRate.Text  = this.objProjectMasterDT.Rows[0]["ProjectRate"].ToString();
            this.txtTimeEstimate.Text = this.objProjectMasterDT.Rows[0]["TimeEstimate"].ToString();
            bool flag = bool.Parse(this.objProjectMasterDT.Rows[0]["CompanyTeam"].ToString());

            this.gvUsers.DataBind();
            this.gvTask.DataBind();
            if (this.gvUsers.Rows.Count > 0 && flag)
            {
                for (int index = 0; index < this.gvUsers.Rows.Count; ++index)
                {
                    CheckBox checkBox = (CheckBox)this.gvUsers.Rows[index].Cells[0].FindControl("chkUserID");
                    if (checkBox.CssClass == "Admin")
                    {
                        checkBox.Checked = true;
                        break;
                    }
                }
            }
            this.objStaffProjectDetailDT = this.objStaffProjectDetailBll.GetDataByProjectID(int.Parse(this.hfProjectID.Value));
            if (this.objStaffProjectDetailDT.Rows.Count > 0)
            {
                for (int index1 = 0; index1 < this.objStaffProjectDetailDT.Rows.Count; ++index1)
                {
                    for (int index2 = 0; index2 < this.gvUsers.Rows.Count; ++index2)
                    {
                        CheckBox checkBox = (CheckBox)this.gvUsers.Rows[index2].Cells[0].FindControl("chkUserID");
                        if (checkBox.CssClass == "Staff" && checkBox.ToolTip == this.objStaffProjectDetailDT.Rows[index1]["StaffID"].ToString())
                        {
                            checkBox.Checked = true;
                            break;
                        }
                    }
                }
            }
            this.objContractorProjectDetailDT = this.objContractorProjectDetailBll.GetDataByProjectID(int.Parse(this.hfProjectID.Value));
            if (this.objContractorProjectDetailDT.Rows.Count > 0)
            {
                for (int index1 = 0; index1 < this.objContractorProjectDetailDT.Rows.Count; ++index1)
                {
                    for (int index2 = 0; index2 < this.gvUsers.Rows.Count; ++index2)
                    {
                        CheckBox checkBox = (CheckBox)this.gvUsers.Rows[index2].Cells[0].FindControl("chkUserID");
                        if (checkBox.CssClass == "Contractor" && checkBox.ToolTip == this.objContractorProjectDetailDT.Rows[index1]["ContractorID"].ToString())
                        {
                            checkBox.Checked = true;
                        }
                    }
                }
            }
            this.objProjectTaskDetailDT = this.objProjectTaskDetailBll.GetDataByProjectID(int.Parse(this.hfProjectID.Value));
            if (this.objProjectTaskDetailDT.Rows.Count <= 0)
            {
                return;
            }
            for (int index = 0; index < this.objProjectTaskDetailDT.Rows.Count; ++index)
            {
                CheckBox checkBox = (CheckBox)this.gvTask.Rows[index].Cells[0].FindControl("chkTaskID");
                if (checkBox.ToolTip == this.objProjectTaskDetailDT.Rows[index]["TaskID"].ToString())
                {
                    checkBox.Checked = true;
                }
            }
        }
Exemple #6
0
        protected void lnkTimesheet_OnClick(object sender, EventArgs e)
        {
            SqlCommand sqlCommand = new SqlCommand("PR_ExportTimesheetTocsv_SelectAll", new SqlConnection(this.conn));

            sqlCommand.CommandType = CommandType.StoredProcedure;
            SqlCommand selectCommand = sqlCommand;

            selectCommand.Parameters.Add(new SqlParameter("@CompanyID", (object)this.hfCompanyID.Value));
            SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(selectCommand);
            DataSet        dataSet        = new DataSet();

            sqlDataAdapter.Fill(dataSet);
            DataTable dataTable = dataSet.Tables[0];

            if (dataTable.Rows.Count <= 0)
            {
                return;
            }
            string str1 = string.Empty;

            foreach (DataColumn dataColumn in (InternalDataCollectionBase)dataTable.Columns)
            {
                str1 = str1 + (object)dataColumn.ColumnName + (string)(object)',';
            }
            string str2 = str1 + "\r\n";

            foreach (DataRow dataRow in (InternalDataCollectionBase)dataTable.Rows)
            {
                foreach (DataColumn dataColumn in (InternalDataCollectionBase)dataTable.Columns)
                {
                    if (dataColumn.ColumnName == "full_name")
                    {
                        bool   flag = false;
                        string str3 = dataRow[dataColumn.ColumnName].ToString();
                        this.objCompanyMasterDT = this.objCompanyMasterBll.GetDataByCompanyUserName(str3);
                        if (this.objCompanyMasterDT.Rows.Count > 0)
                        {
                            dataRow[dataColumn.ColumnName] = (object)this.objCompanyMasterDT.Rows[0]["CompanyContactPerson"].ToString();
                            flag = true;
                        }
                        if (!flag)
                        {
                            this.objStaffMasterDT = this.objStaffMasterBll.GetDataByStaffUserName(str3);
                            if (this.objStaffMasterDT.Rows.Count > 0)
                            {
                                dataRow[dataColumn.ColumnName] = (object)((string)this.objStaffMasterDT.Rows[0]["FirstName"] + (object)" " + (string)this.objStaffMasterDT.Rows[0]["LastName"]);
                            }
                        }
                    }
                    if (dataColumn.ColumnName == "project")
                    {
                        string s = dataRow[dataColumn.ColumnName].ToString();
                        if (!string.IsNullOrEmpty(s))
                        {
                            this.objProjectMasterDT        = this.objProjectMasterBll.GetDataByProjectID(int.Parse(s));
                            dataRow[dataColumn.ColumnName] = (object)this.objProjectMasterDT.Rows[0]["ProjectName"].ToString();
                        }
                        else
                        {
                            dataRow[dataColumn.ColumnName] = (object)"";
                        }
                    }
                    if (dataColumn.ColumnName == "task")
                    {
                        string s = dataRow[dataColumn.ColumnName].ToString();
                        if (!string.IsNullOrEmpty(s))
                        {
                            this.objTaskMasterDT           = this.objTaskMasterBll.GetDataByTaskID(int.Parse(s));
                            dataRow[dataColumn.ColumnName] = (object)this.objTaskMasterDT.Rows[0]["TaskName"].ToString();
                        }
                        else
                        {
                            dataRow[dataColumn.ColumnName] = (object)"";
                        }
                    }
                    str2 = str2 + (object)dataRow[dataColumn.ColumnName].ToString().Replace(",", ";") + (string)(object)',';
                }
                str2 += "\r\n";
            }
            this.Response.Clear();
            this.Response.Buffer = true;
            this.Response.AddHeader("content-disposition", "attachment;filename=" + this.hfCompanyName.Value + "_Timesheets.csv");
            this.Response.Charset     = "";
            this.Response.ContentType = "application/text";
            this.Response.Output.Write(str2);
            this.Response.Flush();
            this.Response.End();
        }