예제 #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            using (var ctx = new dsSPDDataContext())
            {
                List <string> errorMessageHidden = new List <string>();
                trClaim       claim = ctx.trClaims.FirstOrDefault(o => o.noSPD == hiddenSPD.Value);
                trSPD         spd   = ctx.trSPDs.FirstOrDefault(o => o.noSPD == claim.noSPD);
                if (claim == null)
                {
                    errorMessageHidden.Add("Data claim tidak ditemukan, submit tidak bisa diproses");
                }
                if (spd == null)
                {
                    errorMessageHidden.Add("Data spd tidak ditemukan, submit tidak bisa diproses");
                }

                if (errorMessageHidden.Count == 0)
                {
                    claim.status        = "Menunggu approval atasan";
                    claim.isSubmit      = true;
                    claim.isSubmitDate  = DateTime.Now;
                    claim.diubahOleh    = karyawan.nrp;
                    claim.diubahTanggal = DateTime.Now;

                    try
                    {
                        ctx.SubmitChanges();
                    }
                    catch (Exception)
                    {
                        errorMessageHidden.Add("Error submit, gagal merubah data");
                    }
                }

                if (errorMessageHidden.Count == 0)
                {
                    EmailCore.ApprovalClaim(claim.nrpAtasan, spd.noSPD, spd, "Atasan", claim.status);

                    lblSuccess.Text = "Claim Berhasil di Submit";

                    pnlError.Visible   = false;
                    pnlSuccess.Visible = true;
                    btnSave.Enabled    = false;
                    btnSubmit.Enabled  = false;
                    btnReset.Disabled  = true;
                }

                if (errorMessageHidden.Count() > 0)
                {
                    errorMessage.DataSource = errorMessageHidden;
                    errorMessage.DataBind();

                    pnlError.Visible   = true;
                    pnlSuccess.Visible = false;
                }
            }
        }
예제 #2
0
        void ProcessNew(string noSPD)
        {
            noSPD = noSPD.Trim();
            using (var ctx = new dsSPDDataContext())
            {
                var dataSpd  = ctx.trSPDs.FirstOrDefault(o => o.noSPD == noSPD);
                var approval = ctx.ApprovalStatus.Where(o => o.NoSPD == noSPD).OrderBy(o => o.IndexLevel);

                if (dataSpd != null && approval != null)
                {
                    switch (dataSpd.isApproved)
                    {
                    case null:
                        if (approval.Where(o => o.Status == null).Count() == 0)
                        {
                            // proses approval tujuan
                            EmailCore.ApprovalSPD(dataSpd.nrpApprovalTujuan, dataSpd.noSPD, string.Empty, dataSpd);
                        }
                        else
                        {
                            // proses next approval
                            var currentApproval = approval.FirstOrDefault(o => o.Status == null);
                            EmailCore.ApprovalSPD(currentApproval.NrpApproval, dataSpd.noSPD, currentApproval.IndexLevel.ToString(), dataSpd);
                        }

                        break;

                    case true:

                        var dataClaim = ctx.trClaims.FirstOrDefault(o => o.noSPD == noSPD);

                        if (dataClaim != null)
                        {
                            if (dataClaim.isSubmit == true)
                            {
                                if (dataClaim.isApprovedAtasan == null && dataClaim.isApprovedFinance == null && dataClaim.isApprovedGA == null)
                                {
                                    //send approval atasan
                                    EmailCore.ApprovalClaim(dataClaim.nrpAtasan, dataClaim.noSPD, dataSpd, "Atasan", dataClaim.status);
                                }

                                if (dataClaim.isApprovedAtasan == true && dataClaim.isApprovedFinance == null && dataClaim.isApprovedGA == null)
                                {
                                    //send approval GA

                                    var role = (from p in ctx.msUsers
                                                where p.roleId == 17
                                                select p.nrp).ToList();

                                    var dataGa = ctx.msKaryawans
                                                 .Where(o =>
                                                        o.coCd == "0001" &&
                                                        role.Contains(o.nrp));

                                    foreach (var item in dataGa)
                                    {
                                        EmailCore.ApprovalClaim(item.nrp, dataClaim.noSPD, dataSpd, "GA", dataClaim.status);
                                    }
                                }

                                if (dataClaim.isApprovedAtasan == true && dataClaim.isApprovedFinance == null && dataClaim.isApprovedGA == true)
                                {
                                    //send approval Finance

                                    var creator = ctx.msKaryawans.FirstOrDefault(o => o.nrp == dataSpd.nrp);

                                    var role2 = (from p in ctx.msUsers
                                                 where p.roleId == 19
                                                 select p.nrp).ToList();

                                    var datafinace = ctx.msKaryawans
                                                     .Where(o =>
                                                            o.coCd == creator.coCd &&
                                                            role2.Contains(o.nrp));

                                    foreach (var item in datafinace)
                                    {
                                        EmailCore.ApprovalClaim(item.nrp, dataClaim.noSPD, dataSpd, "finance", dataClaim.status);
                                    }
                                }
                            }
                        }

                        // claim
                        break;

                    default:
                        break;
                    }
                }
            }
        }
예제 #3
0
        public string ChangeStatus(string nospd, string action, string nrp, string claimapprove)
        {
            using (var ctx = new dsSPDDataContext())
            {
                try
                {
                    // get data spd & claim
                    var dataClaim = ctx.trClaims.FirstOrDefault(o => o.noSPD == nospd);
                    var dataSpd   = ctx.trSPDs.FirstOrDefault(o => o.noSPD == nospd);

                    if (dataClaim != null && dataSpd != null)
                    {
                        // get user creator nrp

                        // approve
                        if (action.ToLower().Contains("approve"))
                        {
                            if (dataClaim.status.ToLower().Contains("expired"))
                            {
                                return("Claim Expired, sehingga tidak bisa di Approved.");
                            }

                            switch (claimapprove.ToLower())
                            {
                            case "atasan":
                                // jika sudah pernah diapproved/reject return reject alert
                                if (dataClaim.isApprovedAtasan != null)
                                {
                                    string stringStatus = dataClaim.isApprovedAtasan.Value == true ? "approve" : "reject";
                                    if (dataClaim.isApprovedAtasanDate == null)
                                    {
                                        dataClaim.isApprovedAtasanDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah " + stringStatus + " pada : " + dataClaim.isApprovedAtasanDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }
                                // jika sudah di cancel return cancel alert
                                if (dataClaim.isCancel == true)
                                {
                                    if (dataClaim.isCancelDate == null)
                                    {
                                        dataClaim.isCancelDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah dicancel pada : " + dataClaim.isCancelDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }

                                dataClaim.isApprovedAtasan     = true;
                                dataClaim.isApprovedAtasanDate = DateTime.Now;
                                dataClaim.ApprovedAtasanBy     = nrp;
                                dataClaim.status = "Menunggu approval GA";

                                //    var role = (from p in ctx.msUsers
                                //        where p.roleId == 17
                                //   select p.nrp).ToList();

                                //   var dataGa = ctx.msKaryawans
                                //     .Where(o =>
                                //       o.coCd == "0001" &&
                                //      role.Contains(o.nrp));
                                // foreach (var item in dataGa)
                                // {
                                //     EmailCore.ApprovalClaim(item.nrp, dataClaim.noSPD, dataSpd, "ga", dataClaim.status);
                                // }

                                Helper  hp         = new Helper();
                                DataSet dsCheckBcc = hp.wsEmail("claim");
                                if (dsCheckBcc.Tables[0].Rows.Count > 0)
                                {
                                    DataRow  drCheckBcc = dsCheckBcc.Tables[0].Rows[0];
                                    DataView dvCheckBcc = new DataView(dsCheckBcc.Tables[0]);
                                    for (int i = 0; i < dvCheckBcc.Count; i++)
                                    {
                                        //  bccAddress += drCheckBcc.Table.Rows[i][0].ToString();
                                        // bccAddress += ",";
                                        string nrpGA = drCheckBcc.Table.Rows[i][1].ToString();

                                        EmailCore.ApprovalClaim(nrpGA, dataClaim.noSPD, dataSpd, "ga", dataClaim.status);
                                    }
                                }



                                EmailCore.InformasiClaim(dataSpd.dibuatOleh, dataClaim.noSPD, dataSpd, dataClaim.status);

                                break;

                            case "ga":
                                // jika sudah pernah diapproved/reject return reject alert
                                if (dataClaim.isApprovedGA != null)
                                {
                                    string stringStatus = dataClaim.isApprovedGA.Value == true ? "approve" : "reject";
                                    if (dataClaim.isApprovedGADate == null)
                                    {
                                        dataClaim.isApprovedGADate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah " + stringStatus + " pada : " + dataClaim.isApprovedGADate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }
                                // jika sudah di cancel return cancel alert
                                if (dataClaim.isCancel == true)
                                {
                                    if (dataClaim.isCancelDate == null)
                                    {
                                        dataClaim.isCancelDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah dicancel pada : " + dataClaim.isCancelDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }

                                var creator = ctx.msKaryawans.FirstOrDefault(o => o.nrp == dataSpd.nrp);

                                var role2 = (from p in ctx.msUsers
                                             where p.roleId == 19
                                             select p.nrp).ToList();

                                var datafinace = ctx.msKaryawans
                                                 .Where(o =>
                                                        o.coCd == creator.coCd &&
                                                        role2.Contains(o.nrp));

                                foreach (var item in datafinace)
                                {
                                    //EmailCore.ApprovalClaim(item.nrp, dataClaim.noSPD, dataSpd, "finance", dataClaim.status);
                                }

                                // Tambahan Aldo Generate txt
                                var dc    = new dsSPDDataContext();
                                var query = (from a in dc.trClaims
                                             join b in dc.trSPDs on a.noSPD equals b.noSPD
                                             where a.noSPD == nospd
                                             select new
                                {
                                    NoSpd = a.noSPD,
                                    Status = "S",
                                    approvaltgl = DateTime.Now.Date,
                                    NRP = b.nrp,
                                    NamaLengkap = b.namaLengkap,
                                    CostCenter = b.costCenter,
                                    UangMakan = a.biayaMakan,
                                    UangSaku = a.uangSaku,
                                    Tiket = a.tiket,
                                    Hotel = a.hotel,
                                    Laundry = a.laundry,
                                    Komunikasi = a.komunikasi,
                                    AirPortTax = a.airportTax,
                                    BBM = a.BBM,
                                    Tol = a.tol,
                                    Taxi = a.taxi,
                                    Parkir = a.parkir,
                                    Biayalainlain = a.biayaLainLain,
                                    UangMuka = b.uangMuka,
                                    TglBerangkat = b.tglBerangkat,
                                    TglKembali = b.tglKembali
                                }).FirstOrDefault();

                                string approvalDay   = DateTime.Now.Day.ToString();
                                string approvalMonth = DateTime.Now.Month.ToString();
                                string approvalYear  = DateTime.Now.Year.ToString();
                                string _approvaltgl  = approvalDay + "." + approvalMonth + "." + approvalYear;

                                string _CostCenter = string.Empty;
                                string message     = "";
                                message += query.NoSpd + "|";
                                message += query.Status + "|";
                                message += _approvaltgl.Trim() + "|";
                                message += query.NRP + "|";
                                message += query.NamaLengkap + "|";

                                if (query.CostCenter.Split('-').Count() > 0)
                                {
                                    _CostCenter = query.CostCenter.Split('-')[0];
                                }
                                else
                                {
                                    _CostCenter = query.CostCenter;
                                }

                                message += _CostCenter + "|";
                                message += query.UangMakan + "|";
                                message += query.UangSaku + "|";
                                message += query.Tiket + "|";
                                message += query.Hotel + "|";
                                message += query.Laundry + "|";
                                message += query.Komunikasi + "|";
                                message += query.AirPortTax + "|";
                                message += query.BBM + "|";
                                message += query.Tol + "|";
                                message += query.Taxi + "|";
                                message += query.Parkir + "|";
                                message += query.Biayalainlain + "|";
                                message += query.UangMuka + "|";
                                //message += query.TglBerangkat.Day + "." + query.TglBerangkat.Month + "." + query.TglBerangkat.Year + "|";
                                //message += query.TglKembali.Day + "." + query.TglKembali.Month + "." + query.TglKembali.Year;

                                message += query.TglBerangkat.Day + "." + query.TglBerangkat.Month + "." + query.TglBerangkat.Year + "|"; //update 12 oktober 2018
                                message += query.TglKembali.Day + "." + query.TglKembali.Month + "." + query.TglKembali.Year;             //update 12 oktober 2018

                                string tahun   = DateTime.Now.Year.ToString();
                                string bulan   = DateTime.Now.Month.ToString();
                                string tanggal = DateTime.Now.Day.ToString();
                                string jam     = DateTime.Now.Hour.ToString();
                                string menit   = DateTime.Now.Minute.ToString();
                                string detik   = DateTime.Now.Second.ToString();
                                string milisec = DateTime.Now.Millisecond.ToString();

                                string datetime = tahun + bulan + tanggal + "-" + jam + menit + detik + "-" + milisec;
                                string filename = "Settlement_" + datetime + ".txt";

                                //string _User = Encrypto.Decrypt(ConfigurationManager.AppSettings["Username"]);
                                //string _Pass = Encrypto.Decrypt(ConfigurationManager.AppSettings["Password"]);
                                //string _Domain = Encrypto.Decrypt(ConfigurationManager.AppSettings["Domain"]);

                                string _User   = ConfigurationManager.AppSettings["Username"];
                                string _Pass   = ConfigurationManager.AppSettings["Password"];
                                string _Domain = ConfigurationManager.AppSettings["Domain"];

                                string _PathSource       = ConfigurationManager.AppSettings["GenerateText"];
                                string _PathGenerateResp = ConfigurationManager.AppSettings["PathGenerateResp"];
                                string _BackupSett       = ConfigurationManager.AppSettings["BackupSett"];

                                string filePath = string.Format("{0}\\{1}", _PathSource, filename);
                                using (StreamWriter writer = new StreamWriter(filePath, true))
                                {
                                    writer.WriteLine(message);
                                    writer.Close();
                                }

                                string backUpFile      = _BackupSett + filename;
                                string sourceFile      = _PathSource + filename;
                                string destinationFile = _PathGenerateResp + filename;
                                bool   ExistsFile      = false;

                                using (new Impersonator(_User, _Domain, _Pass))
                                {
                                    File.Copy(sourceFile, destinationFile);
                                    if (File.Exists(destinationFile))
                                    {
                                        ExistsFile = true;
                                    }
                                }

                                if (ExistsFile == true)
                                {
                                    File.Move(sourceFile, backUpFile);
                                    ExistsFile = false;
                                }

                                using (new Impersonator(_User, _Domain, _Pass))
                                {
                                    string _PathSapResp                   = ConfigurationManager.AppSettings["PathSapResp"];
                                    string _PathArchiveSapResp            = ConfigurationManager.AppSettings["PathArchiveSapResp"];
                                    List <ListGenerateTextModel> textList = new List <ListGenerateTextModel>();

                                    bool isFileFound = false;
                                    for (int i = 0; i <= 4; i++)
                                    {
                                        foreach (string file in Directory.EnumerateFiles(_PathSapResp, "*.txt"))
                                        {
                                            string        contents     = File.ReadAllText(file);
                                            List <string> cols         = contents.Split(new char[] { '|' }).ToList();
                                            List <string> fileNameList = file.Split(new char[] { '\\' }).ToList();
                                            List <string> textName     = fileNameList.LastOrDefault().Split(new char[] { '_' }).ToList();

                                            string tgl = textName.LastOrDefault().Remove(textName.LastOrDefault().Length - 4, 4);

                                            var           fileDate       = DateTime.ParseExact(tgl, "yyyyMMdd-HHmmss-fff", CultureInfo.InvariantCulture);
                                            string        noSPD          = cols[0];
                                            string        type           = cols[1];
                                            string        messageBPH     = cols.LastOrDefault();
                                            List <string> errorBPHClaims = messageBPH.Split(new char[] { ' ' }).ToList();

                                            string bphNo = errorBPHClaims[4].ToString();

                                            textList.Add(new ListGenerateTextModel()
                                            {
                                                NoSPD = noSPD, NamaFile = Path.GetFileName(file), Type = type, Tanggal = fileDate, Message = messageBPH, BPH = bphNo, FilePath = file
                                            });
                                        }

                                        var data = textList
                                                   .Where(m => m.NoSPD.Contains(dataClaim.noSPD))
                                                   .Where(m => m.Type.Contains("S"))
                                                   .OrderByDescending(m => m.Tanggal)
                                                   .Select(m => new
                                        {
                                            m.NamaFile,
                                            m.FilePath,
                                            m.Message,
                                            m.BPH,
                                            m.Tanggal
                                        }).ToList();

                                        if (data.Count > 0)
                                        {
                                            isFileFound = true;
                                            string archiveSapRespFile;

                                            if (!data[0].Message.ToLower().Contains("successfully"))
                                            {
                                                dataClaim.errorBPHClaim = data[0].Message;
                                                ctx.SubmitChanges();

                                                foreach (var fileMoveFailed in data)
                                                {
                                                    archiveSapRespFile = _PathArchiveSapResp + fileMoveFailed.NamaFile;

                                                    File.Move(fileMoveFailed.FilePath, archiveSapRespFile);
                                                }

                                                return("Claim " + nospd + " gagal di " + action + " karena " + data[0].Message);
                                            }

                                            dataClaim.isApprovedGA     = true;
                                            dataClaim.isApprovedGADate = DateTime.Now;
                                            dataClaim.ApprovedGABy     = nrp;
                                            dataClaim.status           = "Menunggu approval Finance";

                                            dataClaim.errorBPHClaim = data[0].Message;
                                            dataClaim.BPHClaim      = data[0].BPH;

                                            foreach (var fileMoveSuccess in data)
                                            {
                                                archiveSapRespFile = _PathArchiveSapResp + fileMoveSuccess.NamaFile;

                                                File.Move(fileMoveSuccess.FilePath, archiveSapRespFile);
                                            }

                                            break;
                                        }

                                        if (isFileFound)
                                        {
                                            break;
                                        }

                                        Thread.Sleep(5000);
                                    }

                                    if (!isFileFound)
                                    {
                                        return("Claim " + nospd + " gagal di " + action + " karena file SAP tidak ditemukan, silahkan mencoba kembali.");
                                    }
                                }

                                EmailCore.InformasiClaim(dataSpd.dibuatOleh, dataClaim.noSPD, dataSpd, dataClaim.status);

                                break;

                            case "finance":
                                // jika sudah pernah diapproved/reject return reject alert
                                if (dataClaim.isApprovedFinance != null)
                                {
                                    string stringStatus = dataClaim.isApprovedFinance.Value == true ? "approve" : "reject";
                                    if (dataClaim.isApprovedFinanceDate == null)
                                    {
                                        dataClaim.isApprovedFinanceDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah " + stringStatus + " pada : " + dataClaim.isApprovedFinanceDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }
                                // jika sudah di cancel return cancel alert
                                if (dataClaim.isCancel == true)
                                {
                                    if (dataClaim.isCancelDate == null)
                                    {
                                        dataClaim.isCancelDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah dicancel pada : " + dataClaim.isCancelDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }

                                dataClaim.isApprovedFinance     = true;
                                dataClaim.isApprovedFinanceDate = DateTime.Now;
                                dataClaim.ApprovedFinanceBy     = nrp;
                                dataClaim.status = "Finance Approved";

                                EmailCore.InformasiClaim(dataSpd.dibuatOleh, dataClaim.noSPD, dataSpd, dataClaim.status);

                                break;

                            default:
                                break;
                            }
                        }
                        else if (action.ToLower().Contains("reject")) //reject
                        {
                            switch (claimapprove.ToLower())
                            {
                            case "atasan":
                                // jika sudah pernah diapproved/reject return reject alert
                                if (dataClaim.isApprovedAtasan != null)
                                {
                                    string stringStatus = dataClaim.isApprovedAtasan.Value == true ? "approve" : "reject";
                                    if (dataClaim.isApprovedAtasanDate == null)
                                    {
                                        dataClaim.isApprovedAtasanDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah " + stringStatus + " pada : " + dataClaim.isApprovedAtasanDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }
                                // jika sudah di cancel return cancel alert
                                if (dataClaim.isCancel == true)
                                {
                                    if (dataClaim.isCancelDate == null)
                                    {
                                        dataClaim.isCancelDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah dicancel pada : " + dataClaim.isCancelDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }
                                dataClaim.ApprovedAtasanBy     = nrp;
                                dataClaim.isApprovedAtasan     = false;
                                dataClaim.isApprovedAtasanDate = DateTime.Now;

                                break;

                            case "ga":
                                // jika sudah pernah diapproved/reject return reject alert
                                if (dataClaim.isApprovedGA != null)
                                {
                                    string stringStatus = dataClaim.isApprovedGA.Value == true ? "approve" : "reject";
                                    if (dataClaim.isApprovedGADate == null)
                                    {
                                        dataClaim.isApprovedGADate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah " + stringStatus + " pada : " + dataClaim.isApprovedGADate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }
                                // jika sudah di cancel return cancel alert
                                if (dataClaim.isCancel == true)
                                {
                                    if (dataClaim.isCancelDate == null)
                                    {
                                        dataClaim.isCancelDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah dicancel pada : " + dataClaim.isCancelDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }
                                dataClaim.ApprovedGABy     = nrp;
                                dataClaim.isApprovedGA     = false;
                                dataClaim.isApprovedGADate = DateTime.Now;

                                break;

                            case "finance":
                                // jika sudah pernah diapproved/reject return reject alert
                                if (dataClaim.isApprovedFinance != null)
                                {
                                    string stringStatus = dataClaim.isApprovedFinance.Value == true ? "approve" : "reject";
                                    if (dataClaim.isApprovedFinanceDate == null)
                                    {
                                        dataClaim.isApprovedFinanceDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah " + stringStatus + " pada : " + dataClaim.isApprovedFinanceDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }
                                // jika sudah di cancel return cancel alert
                                if (dataClaim.isCancel == true)
                                {
                                    if (dataClaim.isCancelDate == null)
                                    {
                                        dataClaim.isCancelDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah dicancel pada : " + dataClaim.isCancelDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }
                                dataClaim.ApprovedFinanceBy     = nrp;
                                dataClaim.isApprovedFinance     = false;
                                dataClaim.isApprovedFinanceDate = DateTime.Now;

                                break;

                            default:
                                break;
                            }

                            dataClaim.status = "Rejected by " + claimapprove;

                            EmailCore.InformasiClaim(dataSpd.dibuatOleh, dataClaim.noSPD, dataSpd, dataClaim.status);
                        }
                        else if (action.ToLower().Contains("cancel")) //cancel
                        {
                            switch (claimapprove.ToLower())
                            {
                            case "ga":
                                // jika sudah di cancel return cancel alert
                                if (dataClaim.isCancel == true)
                                {
                                    if (dataClaim.isCancelDate == null)
                                    {
                                        dataClaim.isCancelDate = DateTime.Now;
                                    }
                                    return("approval claim tidak bisa dieksekusi, karena claim No Spd : " + nospd + "  telah dicancel pada : " + dataClaim.isCancelDate.Value.ToString("dd MMMM yyyy HH:mm"));
                                }
                                dataClaim.isCancel     = true;
                                dataClaim.isCancelDate = DateTime.Now;
                                dataClaim.status       = "Cancel by " + claimapprove;

                                EmailCore.InformasiClaim(dataSpd.dibuatOleh, dataClaim.noSPD, dataSpd, dataClaim.status);
                                break;

                            default:
                                break;
                            }
                        }
                        else if (action.ToLower().Contains("complete"))
                        {
                            switch (claimapprove.ToLower())
                            {
                            case "ga":
                                dataClaim.TidakExpired = true;
                                ctx.SubmitChanges();
                                return(nospd + " Expired berhasil diperpanjang");

                            default:
                                break;
                            }
                        }

                        ctx.SubmitChanges();
                        return("Claim " + nospd + " berhasil di " + action + " status saat ini berubah menjadi " + dataClaim.status);
                    }
                    else
                    {
                        setErrorLog("Data claim atau spd tidak ditemukan", nospd);
                        return("Claim " + nospd + " gagal di" + action + ", data tidak ditemukan");
                    }
                }
                catch (Exception e)
                {
                    setErrorLog(e, nospd);

                    return(nospd + " _ " + e.Message);
                }
            }
        }
예제 #4
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            #region submit old
            if (Session["noSPDc"] == null)
            {
                Response.Redirect("frmClaimApproval.aspx");
            }
            else
            {
                if (txtNoSPD.Text != string.Empty)
                {
                    dsSPDDataContext data  = new dsSPDDataContext();
                    trClaim          claim = data.trClaims.FirstOrDefault(o => o.noSPD == txtNoSPD.Text);
                    trSPD            spd   = data.trSPDs.FirstOrDefault(o => o.noSPD == claim.noSPD);

                    if (spd.isApproved == true && spd.isCancel == null)
                    {
                        getFromForm(ref claim);

                        try
                        {
                            btnSubmit.Enabled   = false;
                            btnSave.Enabled     = false;
                            claim.nrpAtasan     = spd.nrpAtasan;
                            claim.status        = "Menunggu approval atasan";
                            claim.isSubmit      = true;
                            claim.isSubmitDate  = DateTime.Now;
                            claim.diubahOleh    = karyawan.nrp;
                            claim.diubahTanggal = DateTime.Now;

                            msKaryawan kary = new msKaryawan();
                            if (spd.nrp == "99999999")
                            {
                                kary.EMail        = spd.email;
                                kary.nrp          = spd.nrp;
                                kary.namaLengkap  = spd.namaLengkap;
                                kary.golongan     = "III";
                                kary.Job          = spd.jabatan;
                                kary.posisi       = spd.jabatan;
                                kary.coCd         = "1";
                                kary.kodePSubArea = "1";
                                kary.kodePA       = "1";
                            }
                            else
                            {
                                kary = (from kar in data.msKaryawans
                                        where kar.nrp == spd.nrp
                                        select kar).First();
                            }
                            data.SubmitChanges();


                            EmailCore.ApprovalClaim(claim.nrpAtasan, spd.noSPD, spd, "Atasan", claim.status);

                            lblKet.Text = "Claim berhasil di Submit";
                            data.Dispose();
                        }
                        catch (Exception ex)
                        {
                            Response.Write(ex.Message);
                        }
                    }
                }
            }
            #endregion
        }