Exemple #1
0
        public addUserForm(UserMansubForm f)
        {
            InitializeComponent();
            //职位id列表
            _listJobs       = new List <int>();
            _f              = f;
            txtAddress.Text = "";
            txtIDCARD.Text  = "";
            txtName.Text    = "";
            txtPwd.Text     = "";
            txtQQ.Text      = "";
            txtphone.Text   = "";
            ////查询所有职业
            DataTable dtJobs = JobBLL.SelectAllJob().Tables[0];

            for (int i = 0; i < dtJobs.Rows.Count; i++)
            {
                this.comboxJob.Items.Add(dtJobs.Rows[i][2].ToString());
                _listJobs.Add(Convert.ToInt32(dtJobs.Rows[i][0]));
            }
            this.comboxJob.SelectedIndex = 0;
            //
            this.comboxISadmin.SelectedIndex = 0;
            comboxsex.SelectedIndex          = 0;
        }
Exemple #2
0
        private int AddContainers(int JobId)
        {
            if (ViewState["BookingCntr"] != null)
            {
                Containers = (List <IBookingContainer>)ViewState["BookingCntr"];
            }

            if (Containers.Count > 0)
            {
                foreach (BookingContainerEntity obj in Containers)
                {
                    oJobBll = new JobBLL();
                    //oBookingContainerEntity = new BookingContainerEntity();

                    obj.BookingID = JobId;
                    //oBookingContainerEntity.BookingContainerID = Convert.ToInt32(dt.Rows[i]["BookingContainerID"].ToString());
                    //oBookingContainerEntity.ContainerTypeID = Convert.ToInt32(dt.Rows[i]["ContainerTypeID"].ToString());
                    //oBookingContainerEntity.CntrSize = dt.Rows[i]["CntrSize"].ToString();
                    //oBookingContainerEntity.NoofContainers = Convert.ToInt32(dt.Rows[i]["NoofContainers"].ToString());
                    //oBookingContainerEntity.wtPerCntr = Convert.ToDecimal(dt.Rows[i]["wtPerCntr"].ToString());

                    int res = oJobBll.AddEditJobContainer(obj);
                    if (res != 1)
                    {
                        return(res);
                    }
                }
                return(1);
            }
            return(1);
        }
Exemple #3
0
        private void LoadImportBL()
        {
            if (!ReferenceEquals(Session[Constants.SESSION_USER_INFO], null))
            {
                IUser user = (IUser)Session[Constants.SESSION_USER_INFO];

                if (!ReferenceEquals(Session[Constants.SESSION_SEARCH_CRITERIA], null))
                {
                    SearchCriteria searchCriteria = (SearchCriteria)Session[Constants.SESSION_SEARCH_CRITERIA];

                    if (!ReferenceEquals(searchCriteria, null))
                    {
                        BuildSearchCriteria(searchCriteria);

                        gvImportBL.PageIndex = searchCriteria.PageIndex;

                        if (searchCriteria.PageSize > 0)
                        {
                            gvImportBL.PageSize = searchCriteria.PageSize;
                        }

                        gvImportBL.DataSource = JobBLL.GetJobs(searchCriteria, 0, searchCriteria.JobType);
                        gvImportBL.DataBind();
                    }
                }
            }
        }
Exemple #4
0
 public void LoadObject(int IdObject)
 {
     try
     {
         EmployeeBLL EmployeeBLL = new EmployeeBLL();
         if (EmployeeBLL.GetIdEntity(IdObject) != null)
         {
             EmployeeML Employee = EmployeeBLL.GetIdEntity(IdObject);
             textBoxNumControl.Text = Employee.Id.ToString();
             textBoxNombre.Text     = Employee.Name.ToString();
             textBoxApellidoP.Text  = Employee.LastName.ToString();
             DepartamentBLL DepartamentBLL = new DepartamentBLL();
             DepartamentML  Departament    = DepartamentBLL.GetIdEntity(Employee.IdDepartament);
             textBoxDepartamento.Text = Departament.Name.ToString();
             JobBLL JobBLL = new JobBLL();
             JobML  Job    = JobBLL.GetIdEntity(Employee.IdJob);
             textBoxPuesto.Text = Job.Name;
         }
         else
         {
             cFAT100010 Alert = new cFAT100010("Información", "El empleado no existe", MessageBoxIcon.Information);
             Alert.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(String.Format("LoadObject: {0}", ex), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["jobId"] != null)
            {
                int jobID  = int.Parse(Request.QueryString["jobId"]);
                int userID = int.Parse(Request.Cookies["userInfo"]["id"]);

                if (!CommentBLL.canReadWriteComment(jobID, userID))
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                        "alert('Bạn không có quyền xem bình luận'); window.location='" +
                                                        Request.ApplicationPath + "Job.aspx';", true);
                }

                addComment.HRef = "./CommentForm?jobId=" + jobID;

                List <BO.Comment> commentList = CommentBLL.getAllCommentOfJob(jobID);
                GridView1.DataSource = commentList;
                GridView1.DataBind();

                titlePage.InnerText = "Bình luận công việc: " + JobBLL.getJob(int.Parse(Request.QueryString["jobId"])).title;
            }
            else
            {
                Response.Redirect("Job.aspx");
            }
        }
Exemple #6
0
        protected void UploadButton_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(ViewState["ID"]);

            if (FileUploadControl.HasFile)
            {
                try
                {
                    string originalFilename = Path.GetFileName(FileUploadControl.FileName);
                    string extension        = Path.GetExtension(FileUploadControl.FileName);
                    string filename         = Guid.NewGuid().ToString();

                    FileUploadControl.SaveAs(Server.MapPath("~/Forwarding/Transaction/EstimateFiles/") + filename + "." + extension);
                    hdnFileName.Value = filename;

                    //Update file name in database
                    JobBLL.SaveEstimateFile(id, filename, originalFilename);

                    ClientScript.RegisterStartupScript(typeof(Page), "SymbolError", "<script type='text/javascript'>sendValue();</script>");
                }
                catch (Exception ex)
                {
                    StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message;
                }
            }
        }
Exemple #7
0
        private void DeleteImportBL(int JobId)
        {
            int jobId = JobBLL.DeleteJob(JobId, _userId);

            LoadImportBL();
            ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "<script>javascript:void alert('Job has been deleted successfully!');</script>", false);
        }
Exemple #8
0
        protected void btnDetail_Click(object sender, EventArgs e)
        {
            LinkButton btn = (LinkButton)(sender);

            int id = int.Parse(btn.CommandArgument);

            BO.Job job = JobBLL.getJob(id);

            jobList.Add(job);

            DetailsView1.DataSource = jobList;
            DetailsView1.DataBind();

            switch (DetailsView1.Rows[5].Cells[1].Text)
            {
            case "0": { DetailsView1.Rows[5].Cells[1].Text = "Chưa hoàn thành"; } break;

            case "1": { DetailsView1.Rows[5].Cells[1].Text = "Đã hoàn thành"; } break;
            }

            switch (DetailsView1.Rows[7].Cells[1].Text)
            {
            case "0": { DetailsView1.Rows[7].Cells[1].Text = "Công khai"; } break;

            case "1": { DetailsView1.Rows[7].Cells[1].Text = "Cá nhân"; } break;
            }

            btnEdit.CommandArgument = job.id.ToString();

            mpePopUp.Show();
        }
        public JsonResult Get()
        {
            JobBLL bll = new JobBLL();

            bll._conn = _configuration.GetConnectionString("ATSAppCon");
            List <JobInfo> lst = bll.Get();

            return(new JsonResult(lst));
        }
        public JsonResult Put(JobInfo j)
        {
            JobBLL bll = new JobBLL();

            bll._conn = _configuration.GetConnectionString("ATSAppCon");
            bll.Put(j);

            return(new JsonResult("Updated Successfully"));
        }
        public JsonResult Delete(int id)
        {
            JobBLL bll = new JobBLL();

            bll._conn = _configuration.GetConnectionString("ATSAppCon");
            bll.Delete(id);

            return(new JsonResult("Deleted Successfully"));
        }
Exemple #12
0
 /// <summary>
 /// The constructor of the Jobs controller.
 /// </summary>
 public JobsController(
     ILogger <JobsController> logger,
     IMapper mapper,
     JobBLL bll
     )
 {
     this.logger = logger;
     this.mapper = mapper;
     this.bll    = bll;
 }
Exemple #13
0
        void FillJobContainer(Int32 JobID)
        {
            //oChargeRates = new List<ChargeRateEntity>();
            //oChargeRates = new List<ChargeRateEntity>();
            oJobBll    = new JobBLL();
            Containers = new List <IBookingContainer>();
            Containers = oJobBll.GetJobContainers(JobID);

            ViewState["BookingCntr"] = Containers;

            gvContainer.DataSource = Containers;
            gvContainer.DataBind();
        }
Exemple #14
0
        void binddata()
        {
            //绑定数据
            UserInfo uinfo = new UserInfo();

            uinfo.Uid = this._uid;
            DataTable dt = BLL.UserBLL.selectOneByUID(uinfo).Tables[0];

            this.labuid.Text  = _uid.ToString();
            this.labname.Text = dt.Rows[0][2].ToString();
            //  this.labsex.Text = dt.Rows[0][3].ToString();
            this.labbirth.Text = dt.Rows[0][4].ToString();
            this.labqq.Text    = dt.Rows[0][5].ToString();
            this.labphone.Text = dt.Rows[0][6].ToString();
            department de = new department();

            de.Did           = Convert.ToInt32(dt.Rows[0][7].ToString());
            this.labdid.Text = departmentBLL.selectByDID(de).Tables[0].Rows[0][1].ToString();
            //  this.labjob.Text = dt.Rows[0][8].ToString();
            this.labaddress.Text = dt.Rows[0][9].ToString();
            //  this.labEnable.Text = dt.Rows[0][10].ToString();

            ////初始化控件
            this.Text = "员工信息管理-" + this.labname.Text;
            this.comboxsex.SelectedIndex    = Convert.ToInt32(dt.Rows[0][3]);//男1 女0
            this.comboxEnable.SelectedIndex = Convert.ToInt32(dt.Rows[0][10]);
            ///部门下所有职位
            departjob depart = new departjob();

            depart.Did = Convert.ToInt32(dt.Rows[0][7]);
            DataTable dtAllJobs = JobBLL.selectall().Tables[0];//所有职位(修改职位 的方式可以直接修改所在部门)

            this.comboxjobs.Items.Clear();
            for (int i = 0; i < dtAllJobs.Rows.Count; i++)
            {
                this.comboxjobs.Items.Add(dtAllJobs.Rows[i][2]);
                //保存职位id
                _listjobid.Add(Convert.ToInt32(dtAllJobs.Rows[i][0]));
                if (Convert.ToInt32(dtAllJobs.Rows[i][0]) == Convert.ToInt32(dt.Rows[0][1]))
                {
                    this.comboxjobs.SelectedIndex = i;
                }
            }
        }
Exemple #15
0
        protected void btnDelete_OnClick(object sender, CommandEventArgs e)
        {
            string confirmValue = Request.Form["confirmDeleteJob"];

            if (confirmValue == "Yes")
            {
                int id = int.Parse(btnDelete.CommandArgument);

                if (JobBLL.deleteJob(id))
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                        "alert('Xóa công việc thành công'); window.location='" +
                                                        Request.ApplicationPath + "Job.aspx';", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                        "alert('Xảy ra lỗi'); window.location='" +
                                                        Request.ApplicationPath + "JobForm.aspx';", true);
                }
            }
        }
Exemple #16
0
        public object GetJobByDeptId([FromBody] JObject json)
        {
            try
            {
                string  res          = json.Value <string>("json");
                dynamic dy           = JsonConvert.DeserializeObject <ExpandoObject>(res);
                string  userId       = dy.userid;
                string  DepartmentId = dy.data;
                //long pageIndex = dy.data.pageindex;
                //long pageSize = dy.data.pagesize;
                //获取用户基本信息
                OperatorProvider.AppUserId = userId;  //设置当前用户
                Operator   user       = OperatorProvider.Provider.Current();
                Pagination pagination = new Pagination();
                pagination.page          = 1;
                pagination.rows          = 1000000;
                pagination.sidx          = "createdate";
                pagination.sord          = "desc";
                pagination.p_kid         = "roleid";
                pagination.p_fields      = "t.encode,t.fullname,t.deptname  DepartmentName,t.deptid DepartmentId ";
                pagination.p_tablename   = "base_role t";
                pagination.conditionJson = " category='3' ";
                var queryJson = new
                {
                    deptid = DepartmentId
                };
                //if (!string.IsNullOrWhiteSpace(DepartmentId)) {
                //    pagination.conditionJson += string.Format(@" and deptid='{0}'", DepartmentId);
                //}
                var data = new JobBLL().GetList(pagination, queryJson.ToJson());

                return(new { Code = 0, Count = pagination.records, Info = "获取数据成功", data = data });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, Count = 0, Info = ex.Message });
            }
        }
Exemple #17
0
        public void LoadJobs()
        {
            try
            {
                JobBLL    JobBLL = new JobBLL();
                DataTable Jobs;
                Jobs = JobBLL.All("All");
                comboBoxPuesto.DisplayMember = "Text";
                comboBoxPuesto.ValueMember   = "Value";

                List <Object> items = new List <object>();
                items.Add(new { Text = "Seleccione un opción", Value = "0" });
                foreach (DataRow Job in Jobs.Rows)
                {
                    items.Add(new { Text = Job[JobML.DataBase.Name].ToString(), Value = Job[JobML.DataBase.Id].ToString() });
                }
                comboBoxPuesto.DataSource = items;
            }
            catch (Exception ex)
            {
                MessageBox.Show(String.Format("LoadJobs: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #18
0
        protected void Accept_Add(object sender, EventArgs e)
        {
            BO.Job job = new BO.Job();
            job.user_id = int.Parse(Request.Cookies["userInfo"]["id"]);
            if (title.Value != "")
            {
                job.title = title.Value;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Tên công việc không được bỏ trống')</script>");
                title.Focus();
                return;
            }

            if (startDate.Value != "" && DateTime.Compare(Convert.ToDateTime(startDate.Value).Date, DateTime.Now.Date) == 0)
            {
                job.startDate = Convert.ToDateTime(startDate.Value);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Ngày bắt đầu phải là ngày hiện tại')</script>");
                startDate.Focus();
                return;
            }

            if (finishDate.Value != "" && DateTime.Compare(Convert.ToDateTime(finishDate.Value).Date, Convert.ToDateTime(startDate.Value).Date) >= 0)
            {
                job.finishDate = Convert.ToDateTime(finishDate.Value);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Ngày kết thúc phải sau hoặc cùng ngày bắt đầu')</script>");
                finishDate.Focus();
                return;
            }

            if (coworker.SelectedItem.Value == "0")
            {
                job.coworker = null;
            }
            else
            {
                job.coworker = coworker.SelectedItem.Value;
            }

            job.privacy = int.Parse(privacy.Value);
            job.status  = int.Parse(status.Value);
            string filePath = "";

            if (attach.HasFile)
            {
                if (!JobBLL.CheckFileType(attach.FileName))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('File không phù hợp')</script>");
                    return;
                }
                job.attach = JobBLL.GenerateNameFile(attach.FileName);
                filePath   = MapPath("File/" + job.attach);
            }
            else
            {
                job.attach = null;
            }

            if (JobBLL.addJob(job))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                    "alert('Thêm công việc thành công'); window.location='" +
                                                    Request.ApplicationPath + "Job.aspx';", true);
                if (attach.HasFile)
                {
                    attach.SaveAs(filePath);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                    "alert('Xảy ra lỗi'); window.location='" +
                                                    Request.ApplicationPath + "JobForm.aspx';", true);
            }
        }
Exemple #19
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (ddlJobType.SelectedIndex == 1 || ddlJobType.SelectedIndex == 2)
            {
                if (!string.IsNullOrEmpty(txtMTWeight.Text))
                {
                    if (Convert.ToDecimal(txtMTWeight.Text) == 0)
                    {
                        lblError.Text = "Weight in MT is compulsory";
                        return;
                    }
                    else
                    {
                        lblError.Text = "";
                    }
                }
                else
                {
                    lblError.Text = "Weight in MT is compulsory";
                    return;
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(txtGrossWeight.Text))
                {
                    if (Convert.ToDecimal(txtGrossWeight.Text) == 0)
                    {
                        lblError.Text = "Weight in KG is compulsory";
                        return;
                    }
                }
                else
                {
                    lblError.Text = "Weight in KG is compulsory";
                    return;
                }
            }
            IJob job = new JobEntity();

            if (ViewState["JOBID"] != null)
            {
                job.JobID     = Convert.ToInt32(ViewState["JOBID"]);
                job.JobActive = 'E';
                job.JobNo     = txtJobNo.Text;
            }
            else
            {
                job.JobActive = 'A';
            }

            job.JobTypeID  = ddlJobType.SelectedValue.ToInt();
            job.JobScopeID = ddlJobScope.SelectedValue.ToInt();
            job.JobDate    = Convert.ToDateTime(txtJobDate.Text);
            job.OpsLocID   = ddlOpsControlled.SelectedValue.ToInt();
            job.jobLocID   = ddlDocControlled.SelectedValue.ToInt();
            //job. = ddlDocControlled.SelectedValue.ToInt();
            job.SalesmanID  = ddlSalesControlled.SelectedValue.ToInt();
            job.SmodeID     = ddlShipmentMode.SelectedValue.ToInt();
            job.PrDocID     = ddlPrimeDocs.SelectedValue.ToInt();
            job.PrintHBL    = chkPrintHBL.Checked;
            job.HBLFormatID = ddlHblFormat.SelectedValue.ToInt();
            if (ddlJobType.SelectedIndex == 1 || ddlJobType.SelectedIndex == 2)
            {
                //job.ttl20 = Convert.ToInt32(txtTTL20.Text);
                //job.ttl40 = Convert.ToInt32(txtTTL40.Text);
                if (!string.IsNullOrEmpty(txtMTWeight.Text))
                {
                    job.weightMT = Convert.ToDecimal(txtMTWeight.Text);
                }
                else
                {
                    job.weightMT = 0;
                }

                if (!string.IsNullOrEmpty(txtCBMVolume.Text))
                {
                    job.volCBM = Convert.ToDecimal(txtCBMVolume.Text);
                }
                else
                {
                    job.volCBM = 0;
                }
                //job.RevTon = Convert.ToDecimal(txtRevenue.Text);
            }
            //else if (ddlJobType.SelectedIndex == 3 || ddlJobType.SelectedIndex == 5)
            //{
            //    if (!string.IsNullOrEmpty(txtMTWeight.Text))
            //        job.weightMT = Convert.ToDecimal(txtMTWeight.Text);
            //    else
            //        job.weightMT = 0;

            //    if (!string.IsNullOrEmpty(txtCBMVolume.Text))
            //        job.volCBM = Convert.ToDecimal(txtCBMVolume.Text);
            //    else
            //        job.volCBM = 0;

            //    if (!string.IsNullOrEmpty(txtRevenue.Text))
            //        job.RevTon = Convert.ToDecimal(txtRevenue.Text);
            //    else
            //        job.RevTon = 0;
            //}
            else if (ddlJobType.SelectedIndex == 3 || ddlJobType.SelectedIndex == 4)
            {
                if (!string.IsNullOrEmpty(txtGrossWeight.Text))
                {
                    job.grwt = Convert.ToDecimal(txtGrossWeight.Text);
                }
                else
                {
                    job.grwt = 0;
                }

                if (!string.IsNullOrEmpty(txtVolumeWeight.Text))
                {
                    job.VolWt = Convert.ToDecimal(txtVolumeWeight.Text);
                }
                else
                {
                    job.VolWt = 0;
                }
                //job.RevTon = Convert.ToDecimal(txtRevenue.Text);
            }

            job.PlaceOfReceipt = txtPlaceReciept.Text;
            //job.fk_LportID = ddlPortLoading.SelectedValue.ToInt();
            //job.fk_DportID = ddlPortDischarge.SelectedValue.ToInt();
            job.fk_DportID      = Convert.ToInt32(ViewState["PORTOFDISCHARGEID"]);
            job.fk_LportID      = Convert.ToInt32(ViewState["PORTOFLOADINGID"]);
            job.PlaceOfDelivery = txtDelivery.Text;
            job.FLineID         = ddlShippingLine.SelectedValue.ToInt();
            job.fk_CustID       = ddlCustomer.SelectedValue.ToInt();
            job.fk_CustAgentID  = ddlCustomsAgent.SelectedValue.ToInt();
            job.fk_TransID      = ddlTransporter.SelectedValue.ToInt();
            job.fk_OSID         = ddlOverseasAgent.SelectedValue.ToInt();
            job.CargoSource     = Convert.ToChar(ddlCargoSource.SelectedValue);
            job.CompID          = ddlCompany.SelectedValue.ToInt();
            if (!string.IsNullOrEmpty(txtCreditDays.Text))
            {
                job.CreditDays = Convert.ToInt32(txtCreditDays.Text);
            }
            else
            {
                job.CreditDays = 0;
            }
            //job.CreditDays = Convert.ToInt32(txtCreditDays.Text);
            job.Voyage = txtVoyageNo.Text;
            //job.Vessel = txtVesselName.Text;
            job.DocumentNo = txtDocumentNo.Text;
            job.JobNote1   = txtJobNote1.Text;
            job.JobNote2   = txtJobNote2.Text;
            job.CreatedBy  = _userId;

            int CompanyId = 1;
            int outJobId  = 0;

            int Status = JobBLL.AddEditJob(job, CompanyId, ref outJobId);

            if (Status == 1)
            {
                oJobBll = new JobBLL();
                oJobBll.DeactivateAllContainersAgainstJobId(outJobId);
                AddContainers(outJobId);
            }

            ScriptManager.RegisterStartupScript(this, this.GetType(), "Redit", "alert('Record saved successfully!'); window.location='" + string.Format("{0}://{1}{2}", HttpContext.Current.Request.Url.Scheme, HttpContext.Current.Request.ServerVariables["HTTP_HOST"], (HttpContext.Current.Request.ApplicationPath.Equals("/")) ? string.Empty : HttpContext.Current.Request.ApplicationPath) + "/Forwarding/Transaction/JobList.aspx';", true);
        }
Exemple #20
0
        private void LoadJob()
        {
            SearchCriteria newcriteria = new SearchCriteria();

            SetDefaultSearchCriteria(newcriteria);

            IJob job = JobBLL.GetJobs(newcriteria, Convert.ToInt32(ViewState["JOBID"]), null).SingleOrDefault();

            DisplayJobType(job.JobTypeID);
            if (job.JobTypeID == 1 || job.JobTypeID == 2)
            {
                lnkContainerDtls.Enabled = true;
            }
            else
            {
                lnkContainerDtls.Enabled = false;
            }
            ddlJobType.SelectedValue         = job.JobTypeID.ToString();
            ddlJobScope.SelectedValue        = job.JobScopeID.ToString();
            txtJobDate.Text                  = job.JobDate.ToShortDateString();
            txtJobNo.Text                    = job.JobNo;
            ddlOpsControlled.SelectedValue   = job.OpsLocID.ToString();
            ddlDocControlled.SelectedValue   = job.jobLocID.ToString();
            ddlSalesControlled.SelectedValue = job.SalesmanID.ToString();
            ddlShipmentMode.SelectedValue    = job.SmodeID.ToString();
            ddlShipmentMode_SelectedIndexChanged(null, null);
            ddlPrimeDocs.SelectedValue = job.PrDocID.ToString();

            txtGrossWeight.Text        = job.grwt.ToString();
            txtVolumeWeight.Text       = job.VolWt.ToString();
            txtMTWeight.Text           = job.weightMT.ToString();
            txtCBMVolume.Text          = job.volCBM.ToString();
            txtRevenue.Text            = job.RevTon.ToString();
            txtPlaceReciept.Text       = job.PlaceOfReceipt;
            txtCreditDays.Text         = job.CreditDays.ToString();
            txtDocumentNo.Text         = job.DocumentNo.ToString();
            txtJobNote1.Text           = job.JobNote1.ToString();
            txtJobNote2.Text           = job.JobNote2.ToString();
            txtVoyageNo.Text           = job.Voyage.ToString();
            chkPrintHBL.Checked        = job.PrintHBL;
            ddlHblFormat.SelectedValue = job.HBLFormatID.ToString();
            //Port of Discharge
            string dischargePort = new ImportBLL().GetPortNameById(job.fk_DportID);

            hdnPortDischarge.Value = dischargePort.Split('|')[0].Trim();
            ((TextBox)AC_Port3.FindControl("txtPort")).Text = dischargePort;

            //Port of Loading
            string loadingPort = new ImportBLL().GetPortNameById(job.fk_LportID);

            hdnPortLoading.Value = loadingPort.Split('|')[0].Trim();
            ((TextBox)AC_Port2.FindControl("txtPort")).Text = loadingPort;

            ViewState["PORTOFDISCHARGEID"] = job.fk_DportID;
            ViewState["PORTOFLOADINGID"]   = job.fk_LportID;

            txtDelivery.Text = job.PlaceOfDelivery;
            ddlShippingLine.SelectedValue  = job.FLineID.ToString();
            ddlCustomer.SelectedValue      = job.fk_CustID.ToString();
            ddlCustomsAgent.SelectedValue  = job.fk_CustAgentID.ToString();
            ddlTransporter.SelectedValue   = job.fk_TransID.ToString();
            ddlOverseasAgent.SelectedValue = job.fk_OSID.ToString();
            ddlCargoSource.SelectedValue   = job.CargoSource.ToString();
            ddlCompany.SelectedValue       = job.CompID.ToString();
            if (job.JobActive.ToString() == "C")
            {
                btnSave.Visible = false;
            }
        }
Exemple #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                UserBLL     userBLL  = new UserBLL();
                List <User> listUser = userBLL.getAllUserExceptAdmin();

                userID.DataTextField  = "name";
                userID.DataValueField = "id";
                userID.DataSource     = listUser;
                userID.DataBind();

                User temp = new User();
                temp.id   = 0;
                temp.name = "Không có";
                listUser.Insert(0, temp);

                coworker.DataTextField  = "name";
                coworker.DataValueField = "id";
                coworker.DataSource     = listUser;
                coworker.DataBind();



                if (Request.QueryString["id"] != null)
                {
                    int    id  = int.Parse(Request.QueryString["id"]);
                    BO.Job job = JobBLL.getJob(id);

                    //var localDateTime = DateTime.Now.ToString(""); <---- have to format like that to set value to input date type
                    userID.SelectedValue = job.user_id.ToString();

                    title.Value      = job.title.ToString();
                    startDate.Value  = job.startDate.ToString("yyyy-MM-dd");
                    finishDate.Value = job.finishDate.ToString("yyyy-MM-dd");
                    privacy.Value    = job.privacy.ToString();
                    status.Value     = job.status.ToString();

                    if (job.coworker == null)
                    {
                        coworker.SelectedValue = "0";
                    }
                    else
                    {
                        coworker.SelectedValue = int.Parse(job.coworker).ToString();
                    }

                    if (job.attach != null)
                    {
                        divFileName.InnerText = job.attach;
                    }

                    btnAccept.CommandName     = "Edit";
                    btnAccept.CommandArgument = Request.QueryString["id"];
                    btnDelete.CommandArgument = Request.QueryString["id"];

                    startDate.Disabled = true;

                    lblTitle.Text = "<h3>Sửa công việc " + job.id.ToString() + "</h3>";
                }
                else
                {
                    btnAccept.CommandName = "Add";
                    startDate.Value       = DateTime.Now.ToString("yyyy-MM-dd");
                    lblTitle.Text         = "<h3>Thêm công việc</h3>";
                }
            }
        }
Exemple #22
0
        protected void Accept_Edit(object sender, EventArgs e)
        {
            int id = int.Parse(btnAccept.CommandArgument);

            BO.Job job = new BO.Job();
            job.id      = id;
            job.user_id = int.Parse(userID.SelectedItem.Value);

            if (title.Value != "")
            {
                job.title = title.Value;
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Tên công việc không được bỏ trống')</script>");
                title.Focus();
                return;
            }

            job.startDate = Convert.ToDateTime(startDate.Value);

            if (finishDate.Value != "" &&
                DateTime.Compare(Convert.ToDateTime(finishDate.Value).Date, Convert.ToDateTime(startDate.Value).Date) >= 0 &&
                DateTime.Compare(Convert.ToDateTime(finishDate.Value).Date, DateTime.Now.Date) >= 0)
            {
                job.finishDate = Convert.ToDateTime(finishDate.Value);
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('Ngày kết thúc phải sau hoặc cùng ngày bắt đầu')</script>");
                finishDate.Focus();
                return;
            }

            if (coworker.SelectedItem.Value == "0")
            {
                job.coworker = null;
            }
            else
            {
                job.coworker = coworker.SelectedItem.Value;
            }

            job.privacy = int.Parse(privacy.Value);
            job.status  = int.Parse(status.Value);

            string filePath    = "";
            string currentFile = "";

            if (attach.HasFile)
            {
                if (!JobBLL.CheckFileType(attach.FileName))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Scripts", "<script>alert('File không phù hợp')</script>");
                    return;
                }
                job.attach = JobBLL.GenerateNameFile(attach.FileName);
                filePath   = MapPath("../File/" + job.attach);

                if (divFileName.InnerText != "")
                {
                    currentFile = divFileName.InnerText;
                }
            }
            else
            {
                job.attach = null;
            }

            if (JobBLL.editJob(job))
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                    "alert('Sửa công việc thành công'); window.location='" +
                                                    Request.ApplicationPath + "Manager/Job.aspx';", true);
                if (attach.HasFile)
                {
                    attach.SaveAs(filePath);
                }
                if (currentFile != "")
                {
                    JobBLL.deleteFile(currentFile);
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                    "alert('Xảy ra lỗi'); window.location='" +
                                                    Request.ApplicationPath + "Manager/JobForm.aspx';", true);
            }
        }
        public RJMMutation(
            DocumentBLL documentBLL,
            DocumentTypeBLL documentTypeBLL,
            ResumeBLL resumeBLL,
            ResumeStateBLL resumeStateBLL,
            SkillBLL skillBLL,
            SkillAliasBLL skillAliasBLL,
            JobBLL jobBLL,
            JobStateBLL jobStateBLL
            )
        {
            this.AuthorizeWith("Authorized");

            // Documents
            //FieldAsync<DocumentType>(
            //    "createDocument",
            //    arguments: new QueryArguments(
            //        new QueryArgument<NonNullGraphType<DocumentInputType>>
            //        {
            //            Name = "document"
            //        }
            //    ),
            //    resolve: async context =>
            //    {
            //        Document document = context.GetArgument<Document>("document");

            //        return await context.TryAsyncResolve(
            //            async c => await documentBLL.CreateDocumentAsync(document)
            //        );
            //    }
            //);

            FieldAsync <GraphQLTypes.DocumentType>(
                "updateDocument",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <GraphQLTypes.DocumentInputType> >
            {
                Name = "document"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                Document document = context.GetArgument <Document>("document");

                return(await context.TryAsyncResolve(
                           async c => await documentBLL.UpdateDocumentAsync(document)
                           ));
            }
                );

            FieldAsync <GraphQLTypes.DocumentType>(
                "linkResumeToDocument",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <DocumentResumeInputType> >
            {
                Name = "documentResume"
            }
                    ),
                resolve: async context =>
            {
                DocumentResume documentResume = context.GetArgument <DocumentResume>("documentResume");

                return(await context.TryAsyncResolve(
                           async c => await documentBLL.LinkResumeToDocumentAsync(documentResume)
                           ));
            }
                );

            FieldAsync <GraphQLTypes.DocumentType>(
                "unlinkResumeFromDocument",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <DocumentResumeInputType> >
            {
                Name = "documentResume"
            }
                    ),
                resolve: async context =>
            {
                DocumentResume documentResume = context.GetArgument <DocumentResume>("documentResume");

                return(await context.TryAsyncResolve(
                           async c => await documentBLL.UnlinkResumeFromDocumentAsync(documentResume)
                           ));
            }
                );

            FieldAsync <GraphQLTypes.DocumentType>(
                "removeDocument",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await documentBLL.DeleteDocumentByIdAsync(id)
                           ));
            }
                );

            // DocumentTypes
            FieldAsync <DocumentTypeType>(
                "createDocumentType",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <DocumentTypeInputType> >
            {
                Name = "documentType"
            }
                    ),
                resolve: async context =>
            {
                APIModels.DocumentType documentType = context.GetArgument <APIModels.DocumentType>("documentType");

                return(await context.TryAsyncResolve(
                           async c => await documentTypeBLL.CreateDocumentTypeAsync(documentType)
                           ));
            }
                );

            FieldAsync <DocumentTypeType>(
                "updateDocumentType",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <DocumentTypeInputType> >
            {
                Name = "documentType"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                APIModels.DocumentType documentType = context.GetArgument <APIModels.DocumentType>("documentType");

                return(await context.TryAsyncResolve(
                           async c => await documentTypeBLL.UpdateDocumentTypeAsync(documentType)
                           ));
            }
                );

            FieldAsync <DocumentTypeType>(
                "removeDocumentType",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await documentTypeBLL.DeleteDocumentTypeByIdAsync(id)
                           ));
            }
                );

            // Resumes
            FieldAsync <ResumeType>(
                "createResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeInputType> >
            {
                Name = "resume"
            }
                    ),
                resolve: async context =>
            {
                Resume resume = context.GetArgument <Resume>("resume");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.CreateResumeAsync(resume)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "updateResume",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <ResumeInputType> >
            {
                Name = "resume"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                Resume resume = context.GetArgument <Resume>("resume");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.UpdateResumeAsync(resume)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "linkDocumentToResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <DocumentResumeInputType> >
            {
                Name = "documentResume"
            }
                    ),
                resolve: async context =>
            {
                DocumentResume documentResume = context.GetArgument <DocumentResume>("documentResume");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.LinkDocumentToResumeAsync(documentResume)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "unlinkDocumentFromResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <DocumentResumeInputType> >
            {
                Name = "documentResume"
            }
                    ),
                resolve: async context =>
            {
                DocumentResume documentResume = context.GetArgument <DocumentResume>("documentResume");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.UnlinkDocumentFromResumeAsync(documentResume)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "linkSkillToResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeSkillInputType> >
            {
                Name = "resumeSkill"
            }
                    ),
                resolve: async context =>
            {
                ResumeSkill resumeSkill = context.GetArgument <ResumeSkill>("resumeSkill");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.LinkSkillToResumeAsync(resumeSkill)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "unlinkSkillFromResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeSkillInputType> >
            {
                Name = "resumeSkill"
            }
                    ),
                resolve: async context =>
            {
                ResumeSkill resumeSkill = context.GetArgument <ResumeSkill>("resumeSkill");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.UnlinkSkillFromResumeAsync(resumeSkill)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "removeResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.DeleteResumeByIdAsync(id)
                           ));
            }
                );

            // ResumeStates
            FieldAsync <ResumeStateType>(
                "createResumeState",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeStateInputType> >
            {
                Name = "resumeState"
            }
                    ),
                resolve: async context =>
            {
                ResumeState resumeState = context.GetArgument <ResumeState>("resumeState");

                return(await context.TryAsyncResolve(
                           async c => await resumeStateBLL.CreateResumeStateAsync(resumeState)
                           ));
            }
                );

            FieldAsync <ResumeStateType>(
                "updateResumeState",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <ResumeStateInputType> >
            {
                Name = "resumeState"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                ResumeState resumeState = context.GetArgument <ResumeState>("resumeState");

                return(await context.TryAsyncResolve(
                           async c => await resumeStateBLL.UpdateResumeStateAsync(resumeState)
                           ));
            }
                );

            FieldAsync <ResumeStateType>(
                "removeResumeState",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await resumeStateBLL.DeleteResumeStateByIdAsync(id)
                           ));
            }
                );

            // Skills
            FieldAsync <SkillType>(
                "createSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <SkillInputType> >
            {
                Name = "skill"
            }
                    ),
                resolve: async context =>
            {
                Skill skill = context.GetArgument <Skill>("skill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.CreateSkillAsync(skill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "updateSkill",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <SkillInputType> >
            {
                Name = "skill"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                Skill skill = context.GetArgument <Skill>("skill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.UpdateSkillAsync(skill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "linkResumeToSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeSkillInputType> >
            {
                Name = "resumeSkill"
            }
                    ),
                resolve: async context =>
            {
                ResumeSkill resumeSkill = context.GetArgument <ResumeSkill>("resumeSkill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.LinkResumeToSkillAsync(resumeSkill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "unlinkResumeFromSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeSkillInputType> >
            {
                Name = "resumeSkill"
            }
                    ),
                resolve: async context =>
            {
                ResumeSkill resumeSkill = context.GetArgument <ResumeSkill>("resumeSkill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.UnlinkResumeFromSkillAsync(resumeSkill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "linkJobToSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobSkillInputType> >
            {
                Name = "jobSkill"
            }
                    ),
                resolve: async context =>
            {
                JobSkill jobSkill = context.GetArgument <JobSkill>("jobSkill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.LinkJobToSkillAsync(jobSkill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "unlinkJobFromSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobSkillInputType> >
            {
                Name = "jobSkill"
            }
                    ),
                resolve: async context =>
            {
                JobSkill jobSkill = context.GetArgument <JobSkill>("jobSkill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.UnlinkJobFromSkillAsync(jobSkill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "removeSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.DeleteSkillByIdAsync(id)
                           ));
            }
                );

            // SkillAliases
            FieldAsync <SkillAliasType>(
                "createSkillAlias",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <SkillAliasInputType> >
            {
                Name = "skillAlias"
            }
                    ),
                resolve: async context =>
            {
                SkillAlias skillAlias = context.GetArgument <SkillAlias>("skillAlias");

                return(await context.TryAsyncResolve(
                           async c => await skillAliasBLL.CreateSkillAliasAsync(skillAlias)
                           ));
            }
                );

            FieldAsync <SkillAliasType>(
                "updateSkillAlias",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <SkillAliasInputType> >
            {
                Name = "skillAlias"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                SkillAlias skillAlias = context.GetArgument <SkillAlias>("skillAlias");

                return(await context.TryAsyncResolve(
                           async c => await skillAliasBLL.UpdateSkillAliasAsync(skillAlias)
                           ));
            }
                );

            FieldAsync <SkillAliasType>(
                "removeSkillAlias",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await skillAliasBLL.DeleteSkillAliasByIdAsync(id)
                           ));
            }
                );

            // Jobs
            FieldAsync <JobType>(
                "createJob",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobInputType> >
            {
                Name = "job"
            }
                    ),
                resolve: async context =>
            {
                Job job = context.GetArgument <Job>("job");

                return(await context.TryAsyncResolve(
                           async c => await jobBLL.CreateJobAsync(job)
                           ));
            }
                );

            FieldAsync <JobType>(
                "updateJob",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <JobInputType> >
            {
                Name = "job"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                Job job = context.GetArgument <Job>("job");

                return(await context.TryAsyncResolve(
                           async c => await jobBLL.UpdateJobAsync(job)
                           ));
            }
                );

            FieldAsync <JobType>(
                "linkSkillToJob",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobSkillInputType> >
            {
                Name = "jobSkill"
            }
                    ),
                resolve: async context =>
            {
                JobSkill jobSkill = context.GetArgument <JobSkill>("jobSkill");

                return(await context.TryAsyncResolve(
                           async c => await jobBLL.LinkSkillToJobAsync(jobSkill)
                           ));
            }
                );

            FieldAsync <JobType>(
                "unlinkSkillFromJob",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobSkillInputType> >
            {
                Name = "jobSkill"
            }
                    ),
                resolve: async context =>
            {
                JobSkill jobSkill = context.GetArgument <JobSkill>("jobSkill");

                return(await context.TryAsyncResolve(
                           async c => await jobBLL.UnlinkSkillFromJobAsync(jobSkill)
                           ));
            }
                );

            FieldAsync <JobType>(
                "removeJob",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await jobBLL.DeleteJobByIdAsync(id)
                           ));
            }
                );

            // JobStates
            FieldAsync <JobStateType>(
                "createJobState",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobStateInputType> >
            {
                Name = "jobState"
            }
                    ),
                resolve: async context =>
            {
                JobState jobState = context.GetArgument <JobState>("jobState");

                return(await context.TryAsyncResolve(
                           async c => await jobStateBLL.CreateJobStateAsync(jobState)
                           ));
            }
                );

            FieldAsync <JobStateType>(
                "updateJobState",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <JobStateInputType> >
            {
                Name = "jobState"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                JobState jobState = context.GetArgument <JobState>("jobState");

                return(await context.TryAsyncResolve(
                           async c => await jobStateBLL.UpdateJobStateAsync(jobState)
                           ));
            }
                );

            FieldAsync <JobStateType>(
                "removeJobState",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await jobStateBLL.DeleteJobStateByIdAsync(id)
                           ));
            }
                );
        }
Exemple #24
0
        public object InsertTemporaryPeople([FromBody] JObject jObject)
        {
            var userService = new UserBLL();

            try
            {
                string res = jObject.Value <string>("json");
                var    dy  = JsonConvert.DeserializeAnonymousType(res, new
                {
                    userid = string.Empty,
                    data   = new List <TemporaryPeopleParameter>()
                });
                UserEntity createUser = userService.GetEntity(dy.userid);;
                if (createUser == null)
                {
                    throw new Exception("你没有权限添加权限");
                }

                List <UserEntity> successList = new List <UserEntity>(); //要新增到数据库里的数据
                List <object>     badList     = new List <object>();     //有问题的数据
                foreach (TemporaryPeopleParameter item in dy.data)
                {
                    try
                    {
                        if (!string.IsNullOrWhiteSpace(item.Mobile) && !userService.ExistMoblie(item.Mobile))
                        {
                            //校验手机号是否重复,重复该条数据不让添加
                            badList.Add(new { data = item, msg = "手机号重复" });
                            continue;
                        }
                        //如果账号存在则再生成一个,直到没有重复的为止
                        string pyStr   = Str.PinYin(item.RealName);
                        string account = pyStr;
                        int    count   = 1;
                        while (!userService.ExistAccount(account))
                        {
                            account = pyStr + GetNumStr(count);
                            count++;
                        }

                        UserEntity user = new UserEntity();
                        user.UserId             = Guid.NewGuid().ToString();
                        user.RealName           = item.RealName;
                        user.IdentifyID         = item.IdentifyID;
                        user.Mobile             = item.Mobile;
                        user.Account            = account;
                        user.IdentifyID         = item.IdentifyID;
                        user.IsEpiboly          = "1";
                        user.Gender             = "男";
                        user.OrganizeId         = createUser.OrganizeId;
                        user.OrganizeCode       = createUser.OrganizeCode;
                        user.CreateUserOrgCode  = createUser.OrganizeCode;
                        user.CreateDate         = DateTime.Now;
                        user.CreateUserDeptCode = createUser.DepartmentCode;
                        user.CreateUserId       = createUser.UserId;
                        user.CreateUserName     = createUser.RealName;
                        user.DepartmentId       = createUser.DepartmentId;
                        user.DepartmentCode     = createUser.DepartmentCode;
                        user.Password           = "******";//默认密码123456
                        user.IsPresence         = "1";

                        //岗位随机分配一个本班组下没有负责人角色的岗位
                        IEnumerable <RoleEntity> rlist = new JobBLL().GetList().Where(p => p.DeptId == createUser.DepartmentId && !p.RoleIds.Contains("27eb996b-1294-41d6-b8e6-837645a66819"));
                        if (rlist != null && rlist.Count() > 0)
                        {
                            var defaultRole = rlist.FirstOrDefault();
                            user.DutyId   = defaultRole.RoleId;
                            user.DutyName = defaultRole.FullName;
                        }
                        //	职务:默认为编码管理中排序为最后一个的职务
                        var defaultJob = new JobBLL().GetList().Where(p => p.OrganizeId == createUser.OrganizeId).OrderByDescending(x => x.SortCode).FirstOrDefault();
                        if (defaultJob != null)
                        {
                            user.PostName = defaultJob.FullName;
                            user.PostId   = defaultJob.RoleId;
                            user.PostCode = defaultJob.EnCode;
                        }
                        //角色,默认班组级用户
                        RoleEntity roleEntity = new RoleCache().GetList().Where(a => a.OrganizeId == createUser.OrganizeId || string.IsNullOrWhiteSpace(a.OrganizeId)).Where(p => p.FullName.Contains("班组级用户")).FirstOrDefault();
                        if (roleEntity != null)
                        {
                            user.RoleId = roleEntity.RoleId;
                        }
                        user.RoleName = roleEntity.FullName;
                        roleEntity    = new RoleCache().GetList().Where(a => a.OrganizeId == createUser.OrganizeId || string.IsNullOrWhiteSpace(a.OrganizeId)).Where(p => p.FullName.Contains("普通用户")).FirstOrDefault();
                        if (roleEntity != null)
                        {
                            if (!string.IsNullOrEmpty(roleEntity.RoleId))
                            {
                                user.RoleId   += "," + roleEntity.RoleId;
                                user.RoleName += "," + roleEntity.FullName;
                            }
                            else
                            {
                                user.RoleId  += roleEntity.RoleId;
                                user.RoleName = roleEntity.FullName;
                            }
                        }
                        string objId = userService.SaveForm(user.UserId, user, 0);
                        if (!string.IsNullOrWhiteSpace(objId))
                        {
                            //不为空则添加成功
                            successList.Add(user);
                            if (!string.IsNullOrWhiteSpace(new DataItemDetailBLL().GetItemValue("bzAppUrl")))
                            {
                                user.Password = "******";
                                var task = Task.Factory.StartNew(() =>
                                {
                                    SaveUser(user);
                                });
                            }
                        }
                        else
                        {
                            badList.Add(new { data = item, msg = "添加失败" });
                        }
                    }
                    catch (Exception itemEx)
                    {
                        badList.Add(new { data = item, msg = itemEx.Message });
                    }
                }

                return(new { Code = 0, Info = "操作成功", data = successList.Select(p => new { p.RealName, p.Account, Password = "******" }) });
            }
            catch (Exception ex)
            {
                return(new { Code = -1, info = "操作失败", data = ex.Message });
            }
        }
Exemple #25
0
        public string SaveUser(string keyValue)
        {
            string json     = HttpContext.Current.Request.Params["json"];
            string account  = HttpContext.Current.Request.Params["account"];
            string fileName = DateTime.Now.ToString("yyyyMMdd") + ".log";

            try
            {
                dynamic dy             = JsonConvert.DeserializeObject <ExpandoObject>(json);
                string  LabourNo       = dy.LabourNo;       //工号
                string  WorkKind       = dy.WorkKind;       //工种
                string  Folk           = dy.Folk;           //民族
                string  CurrentWorkAge = dy.CurrentWorkAge; //工种工龄
                string  OldDegree      = dy.OldDegree;      //原始学历
                string  NewDegree      = dy.NewDegree;      //后期学历
                string  Quarters       = dy.Quarters;       //职务名称
                string  Planer         = dy.Planer;         //职务编号
                string  Visage         = dy.Visage;         //政治面貌
                string  Age            = dy.Age;
                string  Native         = dy.Native;
                string  TecLevel       = dy.TecLevel;
                string  JobName        = dy.JobName;
                string  HealthStatus   = dy.HealthStatus;

                JobBLL            jobbll   = new JobBLL();
                List <RoleEntity> rolist   = jobbll.GetList().ToList();
                UserEntity        user     = Newtonsoft.Json.JsonConvert.DeserializeObject <UserEntity>(json);
                UserBLL           userBll  = new UserBLL();
                UserInfoEntity    currUser = userBll.GetUserInfoByAccount(account);
                SetUserInfo(currUser);
                user.Gender         = user.Gender == "1" ? "男" : "女";
                user.IsEpiboly      = "0";
                user.IsPresence     = "1";
                user.IsSpecial      = user.IsSpecial == "" ? "否" : user.IsSpecial;
                user.IsSpecialEqu   = user.IsSpecialEqu == "" ? "否" : user.IsSpecialEqu;
                user.EnCode         = LabourNo;
                user.Craft          = WorkKind;
                user.Nation         = Folk;
                user.CraftAge       = CurrentWorkAge;
                user.Degrees        = OldDegree;
                user.DegreesID      = OldDegree;
                user.LateDegrees    = NewDegree;
                user.LateDegreesID  = NewDegree;
                user.Political      = Visage;
                user.Age            = Age;
                user.Native         = Native;
                user.TechnicalGrade = TecLevel;
                user.JobTitle       = JobName;
                user.HealthStatus   = HealthStatus;
                string jobid = "";
                if (Planer.Trim() != "")
                {
                    string[] planers = Planer.Split(',');
                    foreach (string jobno in planers)
                    {
                        RoleEntity ro = rolist.Where(it => it.EnCode == jobno).FirstOrDefault();
                        if (ro != null)
                        {
                            if (jobid == "")
                            {
                                jobid = ro.RoleId;
                            }
                            else
                            {
                                jobid += "," + ro.RoleId;
                            }
                        }
                    }
                }

                user.PostId   = jobid;
                user.PostName = Quarters;
                user.PostCode = Planer;

                var deptBll = new DepartmentBLL();
                var dept    = deptBll.GetEntity(user.DepartmentId);
                if (dept != null)
                {
                    dept = deptBll.GetEntity(dept.OrganizeId);
                    if (dept != null)
                    {
                        user.OrganizeCode = dept.EnCode;
                        user.OrganizeId   = dept.OrganizeId;
                    }
                }
                if (user.RoleName.Contains("班组长"))
                {
                    user.RoleId   = "2a878044-06e9-4fe4-89f0-ba7bd5a1bde6,d9432a6e-5659-4f04-9c10-251654199714,27eb996b-1294-41d6-b8e6-837645a66819";
                    user.RoleName = "普通用户,班组级用户,负责人";
                }
                if (user.RoleName.Contains("班组成员"))
                {
                    user.RoleId   = "2a878044-06e9-4fe4-89f0-ba7bd5a1bde6,d9432a6e-5659-4f04-9c10-251654199714";
                    user.RoleName = "普通用户,班组级用户";
                }
                if (user.RoleName.Contains("部门管理员"))
                {
                    user.RoleId   = "2a878044-06e9-4fe4-89f0-ba7bd5a1bde6,6c094cef-cca3-4b41-a71b-6ee5e6b89008,27eb996b-1294-41d6-b8e6-837645a66819";
                    user.RoleName = "普通用户,部门级用户,负责人";
                }
                if (user.RoleName.Contains("厂级管理员"))
                {
                    user.RoleId   = "2a878044-06e9-4fe4-89f0-ba7bd5a1bde6,aece6d68-ef8a-4eac-a746-e97f0067fab5,27eb996b-1294-41d6-b8e6-837645a66819,5af22786-e2f2-4a3d-8da3-ecfb16b96f36";
                    user.RoleName = "普通用户,公司级用户,负责人,公司管理员";
                }
                try
                {
                    //处理接收以base64编码后的文件内容
                    if (!string.IsNullOrWhiteSpace(dy.SignImg))
                    {
                        byte[] byteData = byteData = Convert.FromBase64String(dy.SignImg);
                        // string dir = HttpContext.Current.Server.MapPath("~/Resource/sign");
                        DataItemDetailBLL dd   = new DataItemDetailBLL();
                        string            path = dd.GetItemValue("imgPath") + "\\Resource\\sign";
                        if (!System.IO.Directory.Exists(path))
                        {
                            System.IO.Directory.CreateDirectory(path);
                        }
                        string imageName = Guid.NewGuid().ToString() + ".png";
                        System.IO.File.WriteAllBytes(path + "\\" + imageName, byteData);
                        user.SignImg = "/Resource/sign/" + imageName;
                    }
                }
                catch (Exception)
                {
                }
                userBll.SaveForm(keyValue, user);
                System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("~/logs/" + fileName), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ,保存用户成功,同步信息:" + json + "\r\n");
                return("success");
            }
            catch (Exception ex)
            {
                System.IO.File.AppendAllText(HttpContext.Current.Server.MapPath("~/logs/" + fileName), DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " ,保存用户失败,同步信息:" + json + ",异常信息:" + ex.Message + "\r\n");
                return(ex.Message);
            }
        }
Exemple #26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                UserBLL     userBLL  = new UserBLL();
                List <User> listUser = userBLL.getAllUserExceptMe(int.Parse(Request.Cookies["userInfo"]["id"]));

                User temp = new User();
                temp.id   = 0;
                temp.name = "Không có";

                listUser.Insert(0, temp);

                coworker.DataTextField  = "name";
                coworker.DataValueField = "id";
                coworker.DataSource     = listUser;
                coworker.DataBind();

                if (Request.QueryString["id"] != null)
                {
                    if (!JobBLL.canAccess(int.Parse(Request.Cookies["userInfo"]["id"]), int.Parse(Request.QueryString["id"])))
                    {
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect",
                                                            "alert('Bạn không có quyền truy cập'); window.location='" +
                                                            Request.ApplicationPath + "Job.aspx';", true);
                    }


                    int    id  = int.Parse(Request.QueryString["id"]);
                    BO.Job job = JobBLL.getJob(id);

                    //var localDateTime = DateTime.Now.ToString(""); <---- have to format like that to set value to input date type

                    title.Value      = job.title.ToString();
                    startDate.Value  = job.startDate.ToString("yyyy-MM-dd");
                    finishDate.Value = job.finishDate.ToString("yyyy-MM-dd");
                    privacy.Value    = job.privacy.ToString();
                    status.Value     = job.status.ToString();

                    if (job.coworker == null)
                    {
                        coworker.SelectedValue = "";
                    }
                    else
                    {
                        coworker.SelectedValue = int.Parse(job.coworker).ToString();
                    }

                    if (job.attach != null)
                    {
                        divFileName.InnerText = job.attach;
                    }

                    btnAccept.CommandName     = "Edit";
                    btnAccept.CommandArgument = Request.QueryString["id"];
                    btnDelete.CommandArgument = Request.QueryString["id"];

                    if (DateTime.Compare(Convert.ToDateTime(job.finishDate.ToString("yyyy-MM-dd")).Date, DateTime.Now.Date) < 0)
                    {
                        title.Disabled      = true;
                        startDate.Disabled  = true;
                        finishDate.Disabled = true;
                        privacy.Disabled    = true;
                        coworker.Enabled    = false;
                        coworker.CssClass   = "form-control";
                    }

                    lblTitle.Text = "<h3>Sửa công việc " + job.id.ToString() + "</h3>";
                }
                else
                {
                    btnAccept.CommandName = "Add";
                    startDate.Value       = DateTime.Now.ToString("yyyy-MM-dd");
                    lblTitle.Text         = "<h3>Thêm công việc</h3>";
                }
            }
        }