protected void btnSave_Click(object sender, EventArgs e)
    {
        EmpLeaveBalance _dalEmpLeaveBalance = null;
        Hashtable       _htParameters       = null;
        int             iNextID             = 0;

        try
        {
            foreach (GridViewRow row in gvwList.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    string p_Employee_Code = row.Cells[1].Text;
                    string p_ID            = (row.Cells[3].FindControl("lblID") as Label).Text;
                    string p_Quota         = (row.Cells[4].FindControl("txtQuota") as TextBox).Text;
                    string p_Used          = (row.Cells[5].FindControl("txtUsed") as TextBox).Text;
                    string p_Balance       = (row.Cells[6].FindControl("txtBalance") as TextBox).Text;

                    _dalEmpLeaveBalance = new EmpLeaveBalance();
                    _htParameters       = new Hashtable();

                    _htParameters["p_Employee_Code"] = p_Employee_Code;
                    _htParameters["p_Year"]          = ddlYear.SelectedValue;
                    //_htParameters["p_Quota"] = Convert.ToDecimal(string.IsNullOrEmpty(p_Quota) ? "0" : p_Quota);
                    //_htParameters["p_Used"] = Convert.ToDecimal(string.IsNullOrEmpty(p_Used) ? "0" : p_Used);
                    //_htParameters["p_Balance"] = Convert.ToDecimal(string.IsNullOrEmpty(p_Balance) ? "0" : p_Balance);
                    _htParameters["p_Quota"]   = double.Parse(string.IsNullOrEmpty(p_Quota) ? "0" : p_Quota);
                    _htParameters["p_Used"]    = double.Parse(string.IsNullOrEmpty(p_Used) ? "0" : p_Used);
                    _htParameters["p_Balance"] = double.Parse(string.IsNullOrEmpty(p_Balance) ? "0" : p_Balance);


                    if (p_ID == "")
                    {
                        Utility.ApplyDefaultProp(_htParameters);
                        _dalEmpLeaveBalance.Insert(_htParameters, ref iNextID);
                    }
                    else
                    {
                        _htParameters["p_ID"] = p_ID;
                        Utility.ApplyDefaultProp(_htParameters);
                        _dalEmpLeaveBalance.Update(_htParameters);
                        //iNextID = Int32.Parse(lblEmployee_ID.Text);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null);
        }

        //Response.Redirect("lstblbranchdetail.aspx?action=add");
    }
Exemple #2
0
    private void BindGridUpload()
    {
        EmpLeaveBalance _dalEmpLeaveBalance = null;
        Hashtable       htParameters        = null;

        try
        {
            _dalEmpLeaveBalance        = new EmpLeaveBalance();
            htParameters               = new Hashtable();
            htParameters["p_keywords"] = txtSearchListUpload.Text;
            gvwListUpload.DataSource   = _dalEmpLeaveBalance.GetRowsTempBalanceGrid(htParameters);
            gvwListUpload.DataBind();
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null);
        }
    }
    private void BindGrid()
    {
        EmpLeaveBalance _dalEmpLeaveBalance = null;
        Hashtable       _htParameters       = null;

        try
        {
            _dalEmpLeaveBalance = new EmpLeaveBalance();
            _htParameters       = new Hashtable();

            _htParameters["p_keywords"] = txtSearch.Text;
            _htParameters["p_Year"]     = ddlYear.SelectedValue;

            gvwList.DataSource = _dalEmpLeaveBalance.GetRows(_htParameters);
            gvwList.DataBind();
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null);
        }
    }
Exemple #4
0
    protected void btnDeleteUpload_Click(object sender, EventArgs e)
    {
        EmpLeaveBalance _dalEmpLeaveBalance = null;
        Hashtable       htParameters        = null;

        try
        {
            _dalEmpLeaveBalance = new EmpLeaveBalance();
            htParameters        = new Hashtable();

            htParameters["p_user_id"] = Session[SessionKey.CURRENT_USER_SESSION_KEY].ToString().Trim();

            _dalEmpLeaveBalance.DeleteTempBalance(htParameters);
            BindGridUpload();

            Utility.ShowMessageBox(this, Utility.DELETE_VALIDATION_SUCCESS_MESSAGE, null, null, null);
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.DELETE_VALIDATION_FAIL_MESSAGE, ex, null, null);
        }
    }
Exemple #5
0
    public static void BindDDLHRMSYear(DropDownList ddl, string parameters)
    {
        EmpLeaveBalance _dalEmpLeaveBalance = null;
        Hashtable       _htParameters       = null;

        try
        {
            _dalEmpLeaveBalance            = new EmpLeaveBalance();
            _htParameters                  = new Hashtable();
            _htParameters["p_keywords"]    = "";
            _htParameters["p_Employee_ID"] = parameters;

            ddl.DataSource     = _dalEmpLeaveBalance.GetRowsYear(_htParameters);
            ddl.DataValueField = "YEAR";
            ddl.DataTextField  = "YEAR";
            ddl.DataBind();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
    //asfor Karyawan
    private void BindGridPopUpKaryawan()
    {
        EmpLeaveBalance _dalEmpLeaveBalance = null;
        Hashtable       _htParameters       = null;

        try
        {
            _dalEmpLeaveBalance = new EmpLeaveBalance();
            _htParameters       = new Hashtable();

            _htParameters["p_keywords"] = txtSearchKaryawan.Text;
            _htParameters["p_status"]   = "1";
            if (Session[SessionKey.CURRENT_USER_HRMS_ROLE].ToString() == "1")
            {
                _htParameters["p_Employee_Code"] = Session[SessionKey.CURRENT_USER_HRMS_EMP_CODE].ToString();
            }
            gvwListKaryawan.DataSource = _dalEmpLeaveBalance.GetRowsBalanceByEmployee(_htParameters);
            gvwListKaryawan.DataBind();
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null);
        }
    }
Exemple #7
0
    protected void btnDownloadTemplate_OnClick(object sender, EventArgs e)
    {
        EmpLeaveBalance _dalEmpLeaveBalance = null;
        Hashtable       _htParameters       = null;

        try
        {
            _dalEmpLeaveBalance = new EmpLeaveBalance();
            _htParameters       = new Hashtable();

            string empcode = Session[SessionKey.CURRENT_USER_HRMS_EMP_CODE].ToString().Trim();

            _htParameters["p_START_DATE"] = Utility.ToDateTime(txtStartDate.Text);
            _htParameters["p_END_DATE"]   = Utility.ToDateTime(txtEndDate.Text);

            var dt = _dalEmpLeaveBalance.GetRowsTempBalanceDataExcel(_htParameters);

            if (dt.Rows.Count <= 0)
            {
                throw new Exception("No data found for date " + txtStartDate.Text + " to date " + txtEndDate.Text);
            }

            var filename = "employee_leave_quota" + empcode + "_" + Utility.ToDateTime(txtStartDate.Text).ToString("yyyyMMdd");
            var filepath = Server.MapPath(@"~\temp\xls\" + filename);

            var columns = new string[dt.Columns.Count];
            var rows    = new string[dt.Rows.Count];
            var i       = 0;
            foreach (DataColumn col in dt.Columns)
            {
                columns[i] = col.ColumnName;
                i++;
            }
            var builder = new StringBuilder();
            builder.Append(string.Join(",", columns.ToArray())).Append("\n");
            i = 0;
            foreach (DataRow dr in dt.Rows)
            {
                var currentRow = new string[dt.Columns.Count];
                var j          = 0;
                foreach (DataColumn col in dt.Columns)
                {
                    object item = dr[col];
                    currentRow[j] = (item.ToString());
                    j++;
                }
                rows[i] = string.Join(",", currentRow.ToArray());
                i++;
            }
            builder.Append(string.Join("\n", rows.ToArray()));
            Response.Clear();
            Response.ContentType = "text/csv";
            Response.AddHeader("Content-Disposition", "attachment;filename=" + filename + ".csv");
            Response.Write(builder.ToString());
            Response.End();
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null);
        }
    }
Exemple #8
0
    protected void btnUpload_Click(object sender, EventArgs e)
    {
        var valid = true;

        if (!FileUploadControl.HasFile)
        {
            return;
        }
        var filename       = FileUploadControl.FileName;
        var s              = filename.Split('.');
        var extension      = s[s.Length - 1];
        var saveAsFileName = "UploadKtaBatchPayment_" + DateTime.Now.ToString("yyyyMMddhhmmss") + "." + extension;
        var contenttype    = FileUploadControl.PostedFile.ContentType;
        var log            = "";

        try
        {
            if (contenttype == "application/octet-stream" || contenttype == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || contenttype == "application/vnd.ms-excel" || contenttype == "text/csv")
            {
                FileUploadControl.SaveAs(Server.MapPath(@"../../temp/xls/") + saveAsFileName);
                log += "Upload file " + filename + " success.\t" + DateTime.Now.ToString(CultureInfo.InvariantCulture) + "\n\r";
                var uploadedPath = Server.MapPath(@"../../temp/xls/") + saveAsFileName;

                var ctr    = 0;
                var parser = new Microsoft.VisualBasic.FileIO.TextFieldParser(uploadedPath);
                parser.TextFieldType = Microsoft.VisualBasic.FileIO.FieldType.Delimited;
                parser.SetDelimiters(new string[] { "," });

                while (!parser.EndOfData)
                {
                    string[] row = parser.ReadFields();
                    if (ctr == 0)
                    {
                        ctr = 1;
                    }
                    else
                    {
                        if (row != null)
                        {
                            var employee_code = row[0];
                            var employee_name = row[1];
                            var start_date    = row[5];
                            var end_date      = row[6];
                            var Quota         = row[7];

                            if (employee_code != "Employee_NIK")
                            {
                                try
                                {
                                    //InsertXlsRowData(row);
                                    EmpLeaveBalance _dalEmpLeaveBalance = null;
                                    Hashtable       htParameters        = null;

                                    _dalEmpLeaveBalance = new EmpLeaveBalance();
                                    htParameters        = new Hashtable();
                                    var iNextId = 0;
                                    htParameters.Clear();
                                    htParameters["p_Employee_Code"] = employee_code;
                                    htParameters["p_START_DATE"]    = Utility.ToDateTime(start_date);
                                    htParameters["p_END_DATE"]      = Utility.ToDateTime(end_date);
                                    htParameters["p_Quota"]         = Quota;
                                    Utility.ApplyDefaultProp(htParameters);
                                    _dalEmpLeaveBalance.InsertTempBalance(htParameters, ref iNextId);

                                    log += "Insert Data : " + employee_code + " - " + employee_name + " Success.\t" +
                                           DateTime.Now.ToString(CultureInfo.InvariantCulture) + "\n\r";
                                }
                                catch (Exception exc)
                                {
                                    log += "Insert Data : " + employee_code + " - " + employee_name +
                                           " Failed.\t" + exc.InnerException.Message + "\t" +
                                           DateTime.Now.ToString(CultureInfo.InvariantCulture) + "\n\r";
                                    valid = false;
                                    // Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null);
                                }
                            }
                        }
                    }
                }

                Utility.ShowMessageBox(this,
                                       valid ? "Upload Success" : "Upload Success but error in processing data. Check Log for detail info.",
                                       null, "lstblleaveimport.aspx");
                //BindGridUpload();
            }
            else
            {
                Utility.ShowMessageBox(this, "Error Excel Format", null, null);
            }
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, "Upload Failed.", ex, null);
        }

        CreateLog(log);
    }