示例#1
0
        protected void btnDel_Click(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);

                string result = _parti.EditTrainer(action, txtIDHidden.Value, txtNameLa.Value, txtNameEng.Value, dtpBD.Value, sex, status, txtVillage.Value,
                                                   txtDistrict.Value, txtProvince.Value, txtWork_place.Value, txtDepartment.Value, txtPosition.Value, txtDate_of_govermented.Value,
                                                   txtOffice_tel.Value, txtMobile_tel.Value, txtEmail.Value, lblPicUrlPath.InnerText, txtReferDoc1Hidd_I.Value, txtReferDoc2Hidd_I.Value,
                                                   txtReferDoc3Hidd_I.Value, txtReferDoc4Hidd_I.Value, txtReferDoc5Hidd_I.Value, txtUsername.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 (avartaUrl.Value != "~/img/avatar.png")
                    {
                        File.Delete(renamePath);
                    }
                    EditEducation(action);
                    string currentPage = Request.RawUrl;
                    MessageBox.swalModal(this.Page, "success", "ຈັດການຂໍ້ມູນສຳເລັດ...", currentPage);
                    _parti.LoggingAsync("set", "Trainer", "user: "******"username"].ToString() + " had delete a Trainer: " +
                                        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", "Trainer", ex.Message, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "");
            }
        }
示例#2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            wcf.parti.Service1 parti = new wcf.parti.Service1();
            try
            {
                var    action      = "edit";
                string sex         = null;
                string picture_url = null;
                string txtid       = null;
                string status      = 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/") + txtUsername.Value + extension;
                    picture_url = "~/avatar/" + txtUsername.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("trainerdocs/") + "1_" + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("trainerdocs/") + "1_" + txtUsername.Value + extension;
                    picture_url = "trainerdocs/" + "1_" + txtUsername.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("trainerdocs/") + "2_" + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("trainerdocs/") + "2_" + txtUsername.Value + extension;
                    picture_url = "trainerdocs/" + "2_" + txtUsername.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("trainerdocs/") + "3_" + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("trainerdocs/") + "3_" + txtUsername.Value + extension;
                    picture_url = "trainerdocs/" + "3_" + txtUsername.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("trainerdocs/") + "4_" + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("trainerdocs/") + "4_" + txtUsername.Value + extension;
                    picture_url = "trainerdocs/" + "4_" + txtUsername.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("trainerdocs/") + "5_" + imgfile;
                    var extension   = Path.GetExtension(imgfilePath);
                    var renamePath  = Server.MapPath("trainerdocs/") + "5_" + txtUsername.Value + extension;
                    picture_url = "trainerdocs/" + "5_" + txtUsername.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 (action == "add")
                {
                    txtid = txtID.Value;
                }
                else if (action == "edit")
                {
                    txtid = txtIDHidden.Value;
                }

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

                txtid = txtIDHidden.Value;
                var result = parti.EditTrainer(action, txtid, txtNameLa.Value, txtNameEng.Value, dtpBD.Value, sex, status, txtVillage.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, txtReferDoc1Hidd_I.Value, txtReferDoc2Hidd_I.Value,
                                               txtReferDoc3Hidd_I.Value, txtReferDoc4Hidd_I.Value, txtReferDoc5Hidd_I.Value, txtUsername.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")
                {
                    EditEducation(action);
                    MessageBox.swalModal(this.Page, "success", "ຈັດການຂໍ້ມູນສຳເລັດ...", Request.RawUrl);
                    parti.LoggingAsync("set", "User Trainer", "user: "******"username"].ToString() + " had " + action + " a User Trainer: " +
                                       txtid + " on 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", "User Trainer", ex.Message, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), "");
            }
        }