예제 #1
0
        protected void btnDel_OnClick(object sender, EventArgs e)
        {
            wcf.parti.Service1 _parti = new wcf.parti.Service1();
            try
            {
                string action     = "del";
                string sex        = null;
                string status     = null;
                string renamePath = Server.MapPath(txtAvatarHidd_I.Value);

                var result = _parti.EditTrainee(action, txtID.Value, txtNameLA.Value, txtNameEng.Value, dtpBD.Value, sex,
                                                status, txtVill.Value, txtDistrict.Value, txtProvince.Value,
                                                txtWork_place.Value, txtDepartment.Value, txtPosition.Value, txtDate_of_govermented.Value,
                                                txtOffice_tel.Value, txtMobile_tel.Value, txtEmail.Value, txtAvatarHidd_I.Value,
                                                txtID.Value, txtReferDoc1Hidd_I.Value, txtReferDoc2Hidd_I.Value, txtReferDoc3Hidd_I.Value,
                                                txtReferDoc4Hidd_I.Value, txtReferDoc5Hidd_I.Value);

                if (result == "e3")
                {
                    MessageBox.swalModal(this.Page, "info", "e3: ມີລະຫັດນີ້ໃນຖານຂໍ້ມູນແລ້ວ ລອງໃສ່ລະຫັດໃຫມ່...", "");
                }
                else if (result == "e0")
                {
                    MessageBox.swalModal(this.Page, "error", "en:internal error", "");
                }
                else if (result == "e2")
                {
                    MessageBox.swalModal(this.Page, "warning", "e2:connection to dbs error...", "");
                }
                else if (result == "e5")
                {
                    if (txtAvatarHidd_I.Value != "")
                    {
                        File.Delete(renamePath);
                    }
                    EditApproval(action);
                    EditEducation(action);
                    string currentPage = Request.RawUrl;
                    MessageBox.swalModal(this.Page, "success", "ຈັດການຂໍ້ມູນສຳເລັດ...", currentPage);
                    _parti.LoggingAsync("set", "Trainee", "user: "******"username"].ToString() + " had delete a Trainee: " +
                                        txtNameLA.Value + " from system", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "");
                }
            }
            catch (Exception ex)
            {
                MessageBox.swalModal(this.Page, "error", "en:internal error[" + ex.Message.Replace("'", "") + "]", "");
                _parti.LoggingAsync("set", "Trainee", ex.Message, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "");
            }
        }
예제 #2
0
        protected void btnSave_OnClick(object sender, EventArgs e)
        {
            try
            {
                wcf.parti.Service1 parti = new wcf.parti.Service1();
                var    action            = btnState.Value.ToString();
                string sex         = null;
                string status      = null;
                string picture_url = null;
                string txtid       = null;

                if (string.IsNullOrEmpty(imageUpload.PostedFile.FileName) == false)
                {
                    var imgfile     = Path.GetFileName(imageUpload.PostedFile.FileName);
                    var imgfilePath = Server.MapPath("avatar/") + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("avatar/") + txtID.Value + extension;
                    picture_url = "avatar/" + txtID.Value + extension;
                    imageUpload.SaveAs(imgfilePath);
                    if (File.Exists(renamePath))
                    {
                        File.Delete(renamePath);
                    }
                    File.Move(imgfilePath, renamePath);
                    txtAvatarHidd_I.Value = picture_url;
                }
                if (string.IsNullOrEmpty(txtReferDoc1.PostedFile.FileName) == false)
                {
                    var imgfile     = Path.GetFileName(txtReferDoc1.PostedFile.FileName);
                    var imgfilePath = Server.MapPath("traineedocs/") + "1_" + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("traineedocs/") + "1_" + txtID.Value + extension;
                    picture_url = "traineedocs/" + "1_" + txtID.Value + extension;
                    txtReferDoc1.SaveAs(imgfilePath);
                    if (File.Exists(renamePath))
                    {
                        File.Delete(renamePath);
                    }
                    File.Move(imgfilePath, renamePath);
                    txtReferDoc1Hidd.InnerText = picture_url;
                    txtReferDoc1Hidd_I.Value   = picture_url;
                }
                if (string.IsNullOrEmpty(txtReferDoc2.PostedFile.FileName) == false)
                {
                    var imgfile     = Path.GetFileName(txtReferDoc2.PostedFile.FileName);
                    var imgfilePath = Server.MapPath("traineedocs/") + "2_" + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("traineedocs/") + "2_" + txtID.Value + extension;
                    picture_url = "traineedocs/" + "2_" + txtID.Value + extension;
                    txtReferDoc2.SaveAs(imgfilePath);
                    if (File.Exists(renamePath))
                    {
                        File.Delete(renamePath);
                    }
                    File.Move(imgfilePath, renamePath);
                    txtReferDoc2Hidd.InnerText = picture_url;
                    txtReferDoc2Hidd_I.Value   = picture_url;
                }
                if (string.IsNullOrEmpty(txtReferDoc3.PostedFile.FileName) == false)
                {
                    var imgfile     = Path.GetFileName(txtReferDoc3.PostedFile.FileName);
                    var imgfilePath = Server.MapPath("traineedocs/") + "3_" + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("traineedocs/") + "3_" + txtID.Value + extension;
                    picture_url = "traineedocs/" + "3_" + txtID.Value + extension;
                    txtReferDoc3.SaveAs(imgfilePath);
                    if (File.Exists(renamePath))
                    {
                        File.Delete(renamePath);
                    }
                    File.Move(imgfilePath, renamePath);
                    txtReferDoc3Hidd.InnerText = picture_url;
                    txtReferDoc3Hidd_I.Value   = picture_url;
                }
                if (string.IsNullOrEmpty(txtReferDoc4.PostedFile.FileName) == false)
                {
                    var imgfile     = Path.GetFileName(txtReferDoc4.PostedFile.FileName);
                    var imgfilePath = Server.MapPath("traineedocs/") + "4_" + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("traineedocs/") + "4_" + txtID.Value + extension;
                    picture_url = "traineedocs/" + "4_" + txtID.Value + extension;
                    txtReferDoc4.SaveAs(imgfilePath);
                    if (File.Exists(renamePath))
                    {
                        File.Delete(renamePath);
                    }
                    File.Move(imgfilePath, renamePath);
                    txtReferDoc4Hidd.InnerText = picture_url;
                    txtReferDoc4Hidd_I.Value   = picture_url;
                }
                if (string.IsNullOrEmpty(txtReferDoc5.PostedFile.FileName) == false)
                {
                    var imgfile     = Path.GetFileName(txtReferDoc5.PostedFile.FileName);
                    var imgfilePath = Server.MapPath("traineedocs/") + "5_" + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("traineedocs/") + "5_" + txtID.Value + extension;
                    picture_url = "traineedocs/" + "5_" + txtID.Value + extension;
                    txtReferDoc5.SaveAs(imgfilePath);
                    if (File.Exists(renamePath))
                    {
                        File.Delete(renamePath);
                    }
                    File.Move(imgfilePath, renamePath);
                    txtReferDoc5Hidd.InnerText = picture_url;
                    txtReferDoc5Hidd_I.Value   = picture_url;
                }

                if (rdMale.Checked)
                {
                    sex = "m";
                }
                else if (rdFamale.Checked)
                {
                    sex = "f";
                }

                if (rdDivorce.Checked)
                {
                    status = "d";
                }
                else if (rdMarried.Checked)
                {
                    status = "m";
                }
                else if (rdSingle.Checked)
                {
                    status = "s";
                }

                txtid = txtID.Value;
                var result = parti.EditTrainee(action, txtid, txtNameLA.Value, txtNameEng.Value, dtpBD.Value, sex,
                                               status, txtVill.Value, txtDistrict.Value, txtProvince.Value,
                                               txtWork_place.Value, txtDepartment.Value, txtPosition.Value, txtDate_of_govermented.Value,
                                               txtOffice_tel.Value, txtMobile_tel.Value, txtEmail.Value, txtAvatarHidd_I.Value,
                                               txtid, txtReferDoc1Hidd_I.Value, txtReferDoc2Hidd_I.Value, txtReferDoc3Hidd_I.Value,
                                               txtReferDoc4Hidd_I.Value, txtReferDoc5Hidd_I.Value);

                if (result == "e3")
                {
                    MessageBox.swalModal(this.Page, "info", "e3: ມີ ລະຫັດ/ຊື່ຜູ້ໃຊ້ ນີ້ໃນຖານຂໍ້ມູນແລ້ວ ລອງໃສ່ ລະຫັດ/ຊື່ຜູ້ໃຊ້ ໃຫມ່...", "");
                }
                else if (result == "e0")
                {
                    MessageBox.swalModal(this.Page, "error", "en:internal error", "");
                }
                else if (result == "e2")
                {
                    MessageBox.swalModal(this.Page, "warning", "e2:connection to dbs error...", "");
                }
                else if (result == "e5")
                {
                    EditApproval(action);
                    EditEducation(action);
                    MessageBox.swalModal(this.Page, "success", "ຈັດການຂໍ້ມູນສຳເລັດ...", Request.RawUrl);
                }
            }
            catch (Exception ex)
            {
                MessageBox.swalModal(this.Page, "error", "en:internal error[" + ex.Message.Replace("'", "") + "]", "");
            }
        }