Ejemplo n.º 1
0
    private void SaveData()
    {
        HR_CUTI_KUOTA_DAL _dalHR_CUTI_KUOTA_DAL = null;
        Hashtable         _htParameters         = null;
        int iNextID = 0;

        try
        {
            _dalHR_CUTI_KUOTA_DAL = new HR_CUTI_KUOTA_DAL();
            _htParameters         = new Hashtable();

            MPF23.Shared.Mapper.UIToDB.Map(pnlBody.Controls, _htParameters);
            Utility.ApplyDefaultProp(_htParameters);

            if (Request.Params["action"] == "add")
            {
                _dalHR_CUTI_KUOTA_DAL.Insert(_htParameters, ref iNextID);
            }
            else
            {
                _dalHR_CUTI_KUOTA_DAL.Update(_htParameters);
                iNextID = Int32.Parse(lblID.Text);
            }

            Utility.ShowMessageBox(this, Utility.SAVE_DATA_SUCCESS_MESSAGE, null, "kuotacutidtl.aspx?action=edt&id=" + iNextID.ToString());
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.SAVE_DATA_FAIL_MESSAGE, ex, null);
        }
    }
Ejemplo n.º 2
0
    protected void gvwList_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "Edit":
            Response.Redirect("kuotacutidtl.aspx?action=edt&id=" + e.CommandArgument);
            break;

        case "Delete":
            HR_CUTI_KUOTA_DAL _dalHR_CUTI_KUOTA_DAL = null;
            Hashtable         _htParameters         = null;

            try
            {
                _dalHR_CUTI_KUOTA_DAL = new HR_CUTI_KUOTA_DAL();
                _htParameters         = new Hashtable();

                _htParameters["p_id"] = e.CommandArgument.ToString();

                _dalHR_CUTI_KUOTA_DAL.Delete(_htParameters);
                this.BindGrid();
                Response.Redirect("kuotacutilist.aspx");
            }
            catch (Exception ex)
            {
                Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null);
            }
            break;
        }
    }
Ejemplo n.º 3
0
    private void BindGridUpload()
    {
        HR_CUTI_KUOTA_DAL _dalHR_CUTI_KUOTA_DAL = null;
        Hashtable         htParameters          = null;

        try
        {
            _dalHR_CUTI_KUOTA_DAL      = new HR_CUTI_KUOTA_DAL();
            htParameters               = new Hashtable();
            htParameters["p_keywords"] = txtSearchListUpload.Text;
            gvwListUpload.DataSource   = _dalHR_CUTI_KUOTA_DAL.GetRowsTempBalanceGrid(htParameters);
            gvwListUpload.DataBind();
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null);
        }
    }
Ejemplo n.º 4
0
    private void BindGrid()
    {
        HR_CUTI_KUOTA_DAL _dalHR_CUTI_KUOTA_DAL = null;
        Hashtable         _htParameters         = null;

        try
        {
            _dalHR_CUTI_KUOTA_DAL = new HR_CUTI_KUOTA_DAL();
            _htParameters         = new Hashtable();

            _htParameters["p_keywords"] = txtSearch.Text;
            _htParameters["p_STATUS"]   = ddlStatus.SelectedValue;

            if (Session[SessionKey.CURRENT_USER_HRMS_ROLE].ToString() == "1")
            {
                _htParameters["p_NIK"] = Session[SessionKey.CURRENT_USER_HRMS_EMP_CODE].ToString();
                btnImport.Visible      = false;
            }
            else
            {
                btnImport.Visible = true;
            }
            gvwList.DataSource = _dalHR_CUTI_KUOTA_DAL.GetRows(_htParameters);
            gvwList.DataBind();
            string abc = Session[SessionKey.CURRENT_USER_HRMS_ROLE].ToString();
            if (gvwList.Rows.Count > 0)
            {
                if (Session[SessionKey.CURRENT_USER_HRMS_ROLE].ToString() == "1")
                {
                    gvwList.Columns[gvwList.Rows[0].Cells.Count - 1].Visible = false;
                    gvwList.Columns[gvwList.Rows[0].Cells.Count - 2].Visible = false;
                }
                else
                {
                    gvwList.Columns[gvwList.Rows[0].Cells.Count - 1].Visible = true;
                    gvwList.Columns[gvwList.Rows[0].Cells.Count - 2].Visible = true;
                }
            }
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null);
        }
    }
Ejemplo n.º 5
0
    protected void btnProcess_Click(object sender, EventArgs e)
    {
        HR_CUTI_KUOTA_DAL _dalHR_CUTI_KUOTA_DAL = null;
        Hashtable         htParameters          = null;

        try
        {
            _dalHR_CUTI_KUOTA_DAL = new HR_CUTI_KUOTA_DAL();
            htParameters          = new Hashtable();

            htParameters["p_user_id"] = Session[SessionKey.CURRENT_USER_SESSION_KEY].ToString().Trim();
            Utility.ApplyDefaultProp(htParameters);
            _dalHR_CUTI_KUOTA_DAL.TempBalanceUploadProcess(htParameters);
            BindGridUpload();

            Utility.ShowMessageBox(this, Utility.SAVE_DATA_SUCCESS_MESSAGE, null, null, null);
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.SAVE_DATA_FAIL_MESSAGE, ex, null, null);
        }
    }
Ejemplo n.º 6
0
    private void LoadData()
    {
        HR_CUTI_KUOTA_DAL _dalHR_CUTI_KUOTA_DAL = null;
        Hashtable         _htParameters         = null;

        try
        {
            //System.Diagnostics.Debugger.Break();

            _dalHR_CUTI_KUOTA_DAL = new HR_CUTI_KUOTA_DAL();
            _htParameters         = new Hashtable();

            _htParameters["p_id"] = Request.Params["id"];
            DataTable _dt = _dalHR_CUTI_KUOTA_DAL.GetRow(_htParameters);
            MPF23.Shared.Mapper.DBToUI.Map(pnlBody.Controls, _dt.Rows[0]);
            //imgBtnLookUpKaryawan.Enabled = false;
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null);
        }
    }
Ejemplo n.º 7
0
    //asfor Karyawan
    private void BindGridPopUpKaryawan()
    {
        HR_CUTI_KUOTA_DAL _dalHR_CUTI_KUOTA_DAL = null;
        Hashtable         _htParameters         = null;

        try
        {
            _dalHR_CUTI_KUOTA_DAL = new HR_CUTI_KUOTA_DAL();
            _htParameters         = new Hashtable();

            _htParameters["p_keywords"] = txtSearchKaryawan.Text;
            _htParameters["p_status"]   = "1";
            if (Session[SessionKey.CURRENT_USER_HRMS_ROLE].ToString() == "1")
            {
                _htParameters["p_NIK"] = Session[SessionKey.CURRENT_USER_HRMS_EMP_CODE].ToString();
            }
            gvwListKaryawan.DataSource = _dalHR_CUTI_KUOTA_DAL.GetRowsBalanceByEmployee(_htParameters);
            gvwListKaryawan.DataBind();
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, Utility.LOAD_DATA_FAIL_MESSAGE, ex, null, null);
        }
    }
Ejemplo n.º 8
0
    protected void btnDownloadTemplate_OnClick(object sender, EventArgs e)
    {
        HR_CUTI_KUOTA_DAL _dalHR_CUTI_KUOTA_DAL = null;
        Hashtable         _htParameters         = null;

        try
        {
            _dalHR_CUTI_KUOTA_DAL = new HR_CUTI_KUOTA_DAL();
            _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 = _dalHR_CUTI_KUOTA_DAL.GetRowsTempBalanceDataExcel(_htParameters);

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

            var filename = "kuota_cuti_pegawai_" + 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);
        }
    }
Ejemplo n.º 9
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 = "UploadKuotaCutiPegawai_" + 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[4];
                            var end_date      = row[5];
                            var Quota         = row[6];

                            if (employee_code != "NIK")
                            {
                                try
                                {
                                    //InsertXlsRowData(row);
                                    HR_CUTI_KUOTA_DAL _dalHR_CUTI_KUOTA_DAL = null;
                                    Hashtable         htParameters          = null;

                                    _dalHR_CUTI_KUOTA_DAL = new HR_CUTI_KUOTA_DAL();
                                    htParameters          = new Hashtable();
                                    var iNextId = 0;
                                    htParameters.Clear();
                                    htParameters["p_NIK"]        = 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);
                                    _dalHR_CUTI_KUOTA_DAL.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, "kuotacutiimport.aspx");
                //BindGridUpload();
            }
            else
            {
                Utility.ShowMessageBox(this, "Error Excel Format", null, null);
            }
        }
        catch (Exception ex)
        {
            Utility.ShowMessageBox(this, "Upload Failed.", ex, null);
        }

        CreateLog(log);
    }