예제 #1
0
        /// <summary>
        /// To load Grid
        /// </summary>
        private void BindGrid()
        {
            int        ProjectID     = Convert.ToInt32(Session["PROJECT_ID"]);
            ExpenseBLL ExpenseBLLobj = new ExpenseBLL();

            grdExpense.DataSource = ExpenseBLLobj.GetExpenseDataForACC(ProjectID);
            grdExpense.DataBind();
            //btnSave.Visible = false;
            //btnCancel.Visible= false;
        }
예제 #2
0
        protected void Save_Close_Click(object sender, EventArgs e)
        {
            if (isAdd)
            {
                thisReport           = new sdk_expense_report();
                thisReport.status_id = (int)DTO.DicEnum.EXPENSE_REPORT_STATUS.HAVE_IN_HAND;
            }
            else
            {
                thisReport = new sdk_expense_report_dal().FindNoDeleteById(thisReport.id);
            }
            thisReport.title = Request.Form["title"];
            var endDate = DateTime.Now;

            if (DateTime.TryParse(Request.Form["end_date"], out endDate))
            {
                thisReport.end_date = endDate;
                var cash_advance_amount = Request.Form["cash_advance_amount"];
                if (!string.IsNullOrEmpty(cash_advance_amount))
                {
                    thisReport.cash_advance_amount = decimal.Parse(cash_advance_amount);
                }
                else
                {
                    thisReport.cash_advance_amount = null;
                }
                var result = new ExpenseBLL().ReportManage(thisReport, LoginUserId, isCopy, copyId);

                if (result)
                {
                    if (!string.IsNullOrEmpty(pageFrom))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('保存成功!');setTimeout(function () { window.close(); self.opener.location.reload();}, 1000);</script>");
                    }
                    else
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "打开报表", "<script>window.open('../TimeSheet/ExpenseReportDetail.aspx?id=" + thisReport.id + "', '" + (int)OpenWindow.EXPENSE_REPORT_DETAIL + "', 'left=200,top=200,width=900,height=750,resizable=yes', false);</script>");
                        ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('保存成功!');setTimeout(function () { window.close(); self.opener.location.reload();}, 1000);</script>");
                        //
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('保存失败!');</script>");
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('周期结束日期格式不正确!');</script>");
            }
        }
예제 #3
0
        //private void Import_To_Grid(string FilePath, string Extension)
        //{
        //    ExpenseBLL objExpensePopup = new ExpenseBLL();
        //    DataTable dtExpenses = objExpensePopup.ExcelDataImportintoGrid(FilePath, Extension, Convert.ToInt32(Session["PROJECT_ID"]), Convert.ToInt32(Session["USER_ID"]));

        //    grdExpense.DataSource = dtExpenses;
        //    grdExpense.DataBind();
        //

        //    //DataTable dtExpen = (DataTable)ViewState["EXCEL_DATA"];
        //}

        /// <summary>
        /// To Load expence
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnLoadExpense_Click(object sender, EventArgs e)
        {
            ExpenseBLL objExpensePopup = new ExpenseBLL();
            string     filePath        = hdnFilePath.Value;
            string     fileExtension   = "xlsx";

            DataTable dtExpenses = objExpensePopup.ExcelDataImportintoGrid(filePath, fileExtension, Convert.ToInt32(Session["PROJECT_ID"]), Convert.ToInt32(Session["USER_ID"]));

            int validcount = 0;

            string[] cols = new string[4] {
                "ExpenseType", "AccountCode", "ExpenseAmount", "DateOfExpense"
            };
            for (int i = 0; i < dtExpenses.Columns.Count; i++)
            {
                foreach (string col in cols)
                {
                    if (dtExpenses.Columns[i].ToString().ToUpper() == col.ToUpper())
                    {
                        validcount++;
                    }
                }
            }
            if (validcount == 4)
            {
                if (!dtExpenses.Columns.Contains("PROJECTEXPENSEID"))
                {
                    dtExpenses.Columns.Add("PROJECTEXPENSEID", typeof(int));
                }
                grdExpense.Columns[grdExpense.Columns.Count - 1].Visible = false;
                grdExpense.Columns[grdExpense.Columns.Count - 2].Visible = false;
                grdExpense.DataSource = dtExpenses;
                grdExpense.DataBind();
                if (grdExpense.Rows.Count > 0)
                {
                    pnlSave.Visible   = true;
                    btnSave.Visible   = true;
                    btnCancel.Visible = true;
                }
                grdExpense.AllowPaging = false;
                //updExpense.Update();

                ViewState["EXCEL_DATA"] = dtExpenses;
            }
            else
            {
                pnlSave.Visible = false;
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('Invalid File.Please Upload a valid Excel file');", true);
            }
        }
예제 #4
0
        protected void Approval_Click(object sender, EventArgs e)
        {
            var    notifyIds   = Request.Form["notiIds"];
            string faileReason = "";
            var    result      = new ExpenseBLL().Approval(thisReport.id, LoginUserId, out faileReason, notifyIds);

            if (result)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('保存成功!');window.close();self.opener.location.reload();</script>");
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "提示信息", "<script>alert('保存失败!" + faileReason + "');window.close();self.opener.location.reload();</script>");
            }
        }
예제 #5
0
        /// <summary>
        /// Save and Update
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSaveExpence_Click(object sender, EventArgs e)
        {
            ExpenseBO objExpense = new ExpenseBO();


            objExpense.PROJECTEXPENSEID = Convert.ToInt32(ViewState["PROJECTEXPENSEID"]);

            ExpenseBLL objExpenseBLL = new ExpenseBLL();
            string     AlertMessage  = string.Empty;
            string     message       = string.Empty;

            if (objExpense.PROJECTEXPENSEID == 0)
            {
                objExpense.PROJECTID     = Convert.ToInt32(Session["PROJECT_ID"]);
                objExpense.EXPENSETYPE   = txtExpensetype.Text.Trim();
                objExpense.ACCOUNTCODE   = txtAccountcode.Text.Trim();
                objExpense.EXPENSEAMOUNT = Convert.ToDecimal(txtExpenseAmt.Text.Trim());
                objExpense.DATEOFEXPENSE = Convert.ToDateTime(dpDateofexpense.Text.ToString());
                objExpense.UPDATEDBY     = Convert.ToInt32(Session["USER_ID"]);
                message = objExpenseBLL.AddExpense(objExpense);
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data saved successfully.";
                    Clearfields();
                }
            }
            else
            {
                objExpense.PROJECTID     = Convert.ToInt32(Session["PROJECT_ID"]);
                objExpense.EXPENSETYPE   = txtExpensetype.Text.Trim();
                objExpense.ACCOUNTCODE   = txtAccountcode.Text.Trim();
                objExpense.EXPENSEAMOUNT = Convert.ToDecimal(txtExpenseAmt.Text.Trim());
                objExpense.DATEOFEXPENSE = Convert.ToDateTime(dpDateofexpense.Text.ToString());
                objExpense.UPDATEDBY     = Convert.ToInt32(Session["USER_ID"]);
                message = objExpenseBLL.UpdateExpense(objExpense);
                if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                {
                    message = "Data Updated successfully.";
                    Clearfields();
                }
            }
            AlertMessage = "alert('" + message + "');";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", AlertMessage, true);

            grdExpense.AllowPaging = true;
            BindGrid();
        }
예제 #6
0
        /// <summary>
        /// To edit and delete
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void grdExpense_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string message = string.Empty;

            try
            {
                if (e.CommandName == "EditRow")
                {
                    ViewState["PROJECTEXPENSEID"] = e.CommandArgument;
                    ExpenseBLL objExpenseBLL = new ExpenseBLL();
                    ExpenseBO  objExpense    = objExpenseBLL.GetExpenseByID(Convert.ToInt32(ViewState["PROJECTEXPENSEID"]));

                    txtExpenseAmt.Text  = UtilBO.CurrencyFormat(objExpense.EXPENSEAMOUNT);//objExpense.EXPENSEAMOUNT.ToString();
                    txtExpensetype.Text = objExpense.EXPENSETYPE.ToString();
                    txtAccountcode.Text = objExpense.ACCOUNTCODE;
                    if (objExpense.DATEOFEXPENSE != null)
                    {
                        dpDateofexpense.Text = objExpense.DATEOFEXPENSE.ToString(UtilBO.DateFormat);
                    }
                    btnSaveExpence.Text  = "Update";
                    btnClearExpence.Text = "Cancel";
                }
                else if (e.CommandName == "DeleteRow")
                {
                    ExpenseBLL objExpenseBLL = new ExpenseBLL();

                    message = objExpenseBLL.DeleteExpense(Convert.ToInt32(e.CommandArgument));
                    if (string.IsNullOrEmpty(message) || message == "" || message == "null")
                    {
                        message = "Data deleted successfully";
                    }
                    Clearfields();
                    grdExpense.AllowPaging = true;
                    BindGrid();
                }
                if (message != "")
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #7
0
        /// <summary>
        /// Save and Update
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string message   = "";
            string uID       = Session["USER_ID"].ToString();
            int    ProjectID = Convert.ToInt32(Session["PROJECT_ID"]);

            DataTable  dtExpen       = (DataTable)ViewState["EXCEL_DATA"];
            DataTable  Dt            = null;
            ExpenseBLL ExpenseBLLobj = new ExpenseBLL();

            Dt = ExpenseBLLobj.savedata(dtExpen, ProjectID, uID);
            //grdExpense.AllowPaging = true;
            message = "Expense Data added successfully";
            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Added", "alert('" + message + "');", true);
            pnlSave.Visible = false;
            Clearfields();
            grdExpense.AllowPaging = true;
            BindGrid();
        }