Exemplo n.º 1
0
    protected void grid_CustomDataCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewCustomDataCallbackEventArgs e)
    {
        if (Request.QueryString["id"] != null && Request.QueryString["typ"] != null)
        {
            string ItvRec = Request.QueryString["typ"].ToString();
            int    mastId = SafeValue.SafeInt(Request.QueryString["id"], 0);


            for (int i = 0; i < list.Count; i++)
            {
                try
                {
                    int detId = list[i].detId;

                    string sql = "";

                    sql = string.Format(@"select Id from Hr_Person where Id='{0}'", detId);
                    DataTable tab = C2.Manager.ORManager.GetDataSet(sql).Tables[0];
                    if (tab.Rows.Count == 1)
                    {
                        Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(HrPerson), "Id='" + detId + "'");
                        HrPerson person      = C2.Manager.ORManager.GetObject(query) as HrPerson;
                        string   newItvRecId = "<" + mastId + ">";

                        if (ItvRec.ToLower() == "recruitment" && !person.RecruitId.Contains(newItvRecId))
                        {
                            person.RecruitId = person.RecruitId + newItvRecId;
                        }
                        if (ItvRec.ToLower() == "interview" && !person.InterviewId.Contains(newItvRecId))
                        {
                            person.InterviewId = person.InterviewId + newItvRecId;
                        }
                        C2.Manager.ORManager.StartTracking(person, Wilson.ORMapper.InitialState.Updated);
                        C2.Manager.ORManager.PersistChanges(person);
                    }
                }
                catch { }
            }
        }
        else
        {
            e.Result = "Error, Pls refresh your Interview and Recruitment";
        }
    }
Exemplo n.º 2
0
 public Company()
 {
     hr = new HrPerson();
 }
Exemplo n.º 3
0
    private void auto_calculate(int person, int payrollId)
    {
        string    name   = HttpContext.Current.User.Identity.Name;
        bool      action = false;
        decimal   salary = 0;
        DateTime  now    = DateTime.Now;
        string    sql    = string.Format(@"select Person,PayItem,Amt,Remark,'NO' as IsCal from Hr_Quote where Person={0}", person);
        DataTable dt     = ConnectSql_mb.GetDataTable(sql);

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(HrPerson), "Id='" + person + "'");
            HrPerson hr = C2.Manager.ORManager.GetObject(query) as HrPerson;
            if (hr != null)
            {
                DateTime birthday = hr.BirthDay;
                int      age      = now.Year - birthday.Year;
                if (now.Month < birthday.Month || (now.Month == birthday.Month && now.Day < birthday.Day))
                {
                    age--;
                }

                DataRow row        = dt.Rows[i];
                string  department = hr.Department;
                string  payItem    = SafeValue.SafeString(row["PayItem"]);
                string  isCal      = SafeValue.SafeString(row["IsCal"]);
                string  remark     = SafeValue.SafeString(row["Remark"]);
                string  sql_item   = string.Format(@"select Description from Hr_PayItem where (Code='{0}' or Description like '%{0}%')", payItem);
                string  des        = SafeValue.SafeString(ConnectSql_mb.ExecuteScalar(sql_item));
                if (des.ToLower().Contains("basic"))
                {
                    #region Salary
                    //if (isCal == "NO")
                    //{
                    decimal amt = Get_Incentive(hr.Name);
                    if (amt > 0)
                    {
                        salary = SafeValue.SafeDecimal(row["Amt"]) + amt;
                    }
                    else
                    {
                        amt    = Get_MonthlyVC(person);
                        salary = SafeValue.SafeDecimal(row["Amt"]) + amt;
                    }
                    //}
                    if (isCal == "YES")
                    {
                        DateTime beginDate  = txt_from.Date;
                        DateTime resignDate = txt_end.Date;

                        DateTime beginDate1  = txt_from.Date;
                        DateTime resignDate1 = txt_end.Date;

                        sql = string.Format(@"select top 1 BeginDate,ResignDate from Hr_PersonDet1 where Person={0} and month(ResignDate)={1} order by Id", person, txt_end.Date.Month);
                        DataTable dt_det1 = ConnectSql_mb.GetDataTable(sql);
                        if (dt_det1.Rows.Count > 0)
                        {
                            for (int j = 0; j < dt_det1.Rows.Count; j++)
                            {
                                beginDate   = SafeValue.SafeDate(dt_det1.Rows[j]["BeginDate"], now);
                                resignDate  = SafeValue.SafeDate(dt_det1.Rows[j]["ResignDate"], now);
                                beginDate1  = beginDate.AddDays(1 - beginDate.Day);                            //这个月的第一天
                                resignDate1 = resignDate.AddDays(1 - resignDate.Day).AddMonths(1).AddDays(-1); //这个月的最后一天
                            }
                        }
                        else
                        {
                            beginDate1  = beginDate.AddDays(1 - beginDate.Day);                            //这个月的第一天
                            resignDate1 = resignDate.AddDays(1 - resignDate.Day).AddMonths(1).AddDays(-1); //这个月的最后一天
                        }
                        sql = string.Format(@"select WorkDays from Hr_MastData where Type='Department' and Code='{0}'", department);
                        decimal  workDays = SafeValue.SafeDecimal(ConnectSql_mb.ExecuteScalar(sql));
                        TimeSpan span     = resignDate - beginDate;
                        TimeSpan span1    = resignDate1 - beginDate1;
                        int      days     = Get_TotalWorkDays(beginDate, resignDate, workDays) + 1;
                        int      days1    = Get_TotalWorkDays(beginDate1, resignDate1, workDays) + 1;


                        decimal dayRate = SafeValue.ChinaRound(salary / days1, 2);

                        salary = SafeValue.ChinaRound(dayRate * days, 2);
                        sql    = string.Format(@"insert into Hr_PayrollDet(PayrollId,ChgCode,Description,Amt,CreateBy,CreateDateTime,Before) values({0},'{1}','{2}',{3},'{4}',getdate(),{3})", payrollId, payItem, remark, salary, name);

                        ConnectSql.ExecuteSql(sql);
                    }
                    action = true;
                    #endregion
                }
                if (action)
                {
                    #region CPF
                    if ((des.ToLower().Contains("cpf employee") || des.ToLower().Contains("employee cpf")) && isCal == "YES")
                    {
                        decimal   amt      = 0;
                        string    sql_rate = string.Format(@"select Rate from Hr_Rate where (Age<{0} and Age1>{0}) and PayItem='{1}'", age, payItem);
                        DataTable dt_rate  = ConnectSql_mb.GetDataTable(sql_rate);
                        if (dt_rate.Rows.Count > 0)
                        {
                            amt = -SafeValue.ChinaRound(salary * (SafeValue.SafeDecimal(dt_rate.Rows[0]["Rate"]) / 100), 2);
                        }
                        sql = string.Format(@"insert into Hr_PayrollDet(PayrollId,ChgCode,Description,Amt,CreateBy,CreateDateTime,Before) values({0},'{1}','{2}',{3},'{4}',getdate(),{3})", payrollId, payItem, remark, amt, name);

                        ConnectSql.ExecuteSql(sql);
                    }
                    if ((des.ToLower().Contains("cpf employer") || des.ToLower().Contains("employer cpf")) && isCal == "YES")
                    {
                        decimal   amt      = 0;
                        string    sql_rate = string.Format(@"select Rate from Hr_Rate where (Age<{0} and Age1>{0}) and PayItem='{1}'", age, payItem);
                        DataTable dt_rate  = ConnectSql_mb.GetDataTable(sql_rate);
                        if (dt_rate.Rows.Count > 0)
                        {
                            amt = SafeValue.ChinaRound(salary * (SafeValue.SafeDecimal(dt_rate.Rows[0]["Rate"]) / 100), 2);
                        }
                        sql = string.Format(@"insert into Hr_PayrollDet(PayrollId,ChgCode,Description,Amt,CreateBy,CreateDateTime,Before) values({0},'{1}','{2}',{3},'{4}',getdate(),{3})", payrollId, payItem, remark, amt, name);

                        ConnectSql.ExecuteSql(sql);
                    }
                    #endregion
                    #region Monthy Variable Component
                    if (payItem == "MonthlyVC" && isCal == "YES")
                    {
                        decimal amt = Get_Incentive(hr.Name);
                        sql = string.Format(@"insert into Hr_PayrollDet(PayrollId,ChgCode,Description,Amt,CreateBy,CreateDateTime,Before) values({0},'{1}','{2}',{3},'{4}',getdate(),{3})", payrollId, payItem, remark, amt, name);
                        ConnectSql.ExecuteSql(sql);
                    }
                    #endregion
                    #region SDL
                    if (payItem == "SDL" && isCal == "YES")
                    {
                        decimal amt = SafeValue.ChinaRound(salary * SafeValue.SafeDecimal(0.0025), 2);
                        if (amt > SafeValue.SafeDecimal(11.25))
                        {
                            amt = SafeValue.SafeDecimal(11.25);
                        }
                        sql = string.Format(@"insert into Hr_PayrollDet(PayrollId,ChgCode,Description,Amt,CreateBy,CreateDateTime,Before) values({0},'{1}','{2}',{3},'{4}',getdate(),{3})", payrollId, payItem, remark, amt, name);
                        ConnectSql.ExecuteSql(sql);
                    }
                    #endregion
                }
            }
        }
    }
Exemplo n.º 4
0
 public bool UpdatePerson(HrPerson instance)
 {
     return(NHibernateHelper.UpdateItem <HrPerson>(_ => _.Id == instance.Id, instance));
 }
Exemplo n.º 5
0
 public bool CreatePerson(HrPerson instance)
 {
     return(NHibernateHelper.Create <HrPerson>(instance, h => h.UniqID == 0, h => h.UniqID == instance.UniqID));
 }
Exemplo n.º 6
0
    protected void AddOrUpdate()
    {
        try
        {
            ASPxPageControl pageControl = this.grid.FindEditFormTemplateControl("pageControl") as ASPxPageControl;
            ASPxTextBox     txt_Id      = this.grid.FindEditFormTemplateControl("txt_Id") as ASPxTextBox;
            ASPxTextBox     txt_Name    = grid.FindEditFormTemplateControl("txt_Name") as ASPxTextBox;
            ASPxTextBox     txtIcNo     = pageControl.FindControl("txtIcNo") as ASPxTextBox;
            string          Id          = SafeValue.SafeString(txt_Id.Text, "");
            string          name        = txt_Name.Text;
            //throw new Exception(name);
            Wilson.ORMapper.OPathQuery query = new Wilson.ORMapper.OPathQuery(typeof(HrPerson), "Id='" + Id + "'");
            HrPerson person = C2.Manager.ORManager.GetObject(query) as HrPerson;
            bool     action = false;

            if (SafeValue.SafeString(txt_Name.Text, "") == "")
            {
                throw new Exception("Name not be null!!!");
                return;
            }
            //if (SafeValue.SafeString(txtIcNo.Text,"") == "")
            //{
            //    throw new Exception("Ic No not be null!!!");
            //    return;
            //}
            string sql = string.Format(@"select count(*) from Hr_Person where IcNo='{0}' and Id<>{1}", SafeValue.SafeString(txtIcNo.Text, ""), SafeValue.SafeString(txt_Id.Text, "0"));
            //string sql=string.Format(@"select count(*) from Hr_Person where Id={0}",SafeValue.SafeString(txt_Id.Text,""),SafeValue.SafeString(txt_Name.Text,""));
            //throw new Exception(sql);
            int cnt = SafeValue.SafeInt(C2.Manager.ORManager.ExecuteScalar(sql), 0);
            if (cnt > 0)
            {
                throw new Exception("Please enter another value of the Ic No again!");
                return;
            }
            if (person == null || person.Id == 0)
            {
                action = true;
                person = new HrPerson();
            }
            //throw new Exception(name);
            person.Name = name;
            ASPxTextBox interviewId = this.grid.FindEditFormTemplateControl("txt_InterviewId") as ASPxTextBox;
            person.InterviewId = SafeValue.SafeString(interviewId.Text, "");
            ASPxTextBox recruitId = this.grid.FindEditFormTemplateControl("txt_RecruitId") as ASPxTextBox;
            person.RecruitId = SafeValue.SafeString(recruitId.Text, "");
            ASPxComboBox gender = pageControl.FindControl("cbo_Gender") as ASPxComboBox;
            person.Gender = gender.Text;
            ASPxTextBox icno = pageControl.FindControl("txtIcNo") as ASPxTextBox;
            person.IcNo = icno.Text;

            ASPxDateEdit birthday = pageControl.FindControl("date_Birthday") as ASPxDateEdit;
            person.BirthDay = birthday.Date;

            ASPxTextBox ss1 = pageControl.FindControl("txt_s1") as ASPxTextBox;
            person.Status1 = S.Text(ss1.Text);
            ASPxTextBox ss2 = pageControl.FindControl("txt_s2") as ASPxTextBox;
            person.Status2 = S.Text(ss2.Text);

            ASPxDateEdit dd1 = pageControl.FindControl("date_d1") as ASPxDateEdit;
            person.Date1 = S.Date(dd1.Date);
            ASPxDateEdit dd2 = pageControl.FindControl("date_d2") as ASPxDateEdit;
            person.Date2 = S.Date(dd2.Date);


            ASPxButtonEdit country = pageControl.FindControl("txt_Country") as ASPxButtonEdit;
            person.Country = country.Text;
            ASPxTextBox race = pageControl.FindControl("txt_Race") as ASPxTextBox;
            person.Race = race.Text;
            ASPxTextBox religion = pageControl.FindControl("txt_Religion") as ASPxTextBox;
            person.Religion = religion.Text;
            ASPxCheckBox married = pageControl.FindControl("ckb_Married") as ASPxCheckBox;
            if (married.Checked)
            {
                person.Married = "Y";
            }
            else
            {
                person.Married = "N";
            }
            ASPxTextBox telephone = pageControl.FindControl("txt_Telephone") as ASPxTextBox;
            person.Telephone = telephone.Text;
            ASPxTextBox email = pageControl.FindControl("txt_Email") as ASPxTextBox;
            person.Email = email.Text;
            ASPxComboBox hrGroup = pageControl.FindControl("cmb_HrGroup") as ASPxComboBox;
            person.HrGroup = hrGroup.Text;
            ASPxComboBox department = pageControl.FindControl("cmb_Department") as ASPxComboBox;
            person.Department = department.Text;
            ASPxComboBox hrRole = pageControl.FindControl("cmb_Role") as ASPxComboBox;
            person.HrRole = hrRole.Text;
            ASPxMemo address = pageControl.FindControl("memo_Address") as ASPxMemo;
            person.Address = address.Text;
            ASPxMemo remark = pageControl.FindControl("memo_Remark") as ASPxMemo;
            person.Remark = remark.Text;
            ASPxMemo remark1 = pageControl.FindControl("memo_Profile") as ASPxMemo;
            person.Remark1 = remark1.Text;
            ASPxMemo remark2 = pageControl.FindControl("memo_Work") as ASPxMemo;
            person.Remark2 = remark2.Text;
            ASPxMemo remark3 = pageControl.FindControl("memo_Education") as ASPxMemo;
            person.Remark3 = remark3.Text;
            ASPxMemo remark4 = pageControl.FindControl("memo_Family") as ASPxMemo;
            person.Remark4 = remark4.Text;
            ASPxMemo remark5 = pageControl.FindControl("memo_Emergency") as ASPxMemo;
            person.Remark5 = remark5.Text;
            ASPxSpinEdit spin_Amount1 = pageControl.FindControl("spin_Amount1") as ASPxSpinEdit;
            person.Amount1 = SafeValue.SafeDecimal(spin_Amount1.Value);
            ASPxSpinEdit spin_Amount2 = pageControl.FindControl("spin_Amount2") as ASPxSpinEdit;
            person.Amount2 = SafeValue.SafeDecimal(spin_Amount2.Value);
            ASPxSpinEdit spin_Amount3 = pageControl.FindControl("spin_Amount3") as ASPxSpinEdit;
            person.Amount3 = SafeValue.SafeDecimal(spin_Amount3.Value);
            //throw new Exception(person.Name);
            if (action)
            {
                person.Status         = txt_Status.Text;
                person.CreateBy       = HttpContext.Current.User.Identity.Name;
                person.CreateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(person, Wilson.ORMapper.InitialState.Inserted);
                Manager.ORManager.PersistChanges(person);
            }
            else
            {
                ASPxComboBox newStatus = grid.FindEditFormTemplateControl("cmb_Type") as ASPxComboBox;
                person.Status = newStatus.Text;
                string oldStatus = SafeValue.SafeString(C2.Manager.ORManager.ExecuteScalar(string.Format("select Status from Hr_Person where Id={0}", Id)));
                if (oldStatus != SafeValue.SafeString(newStatus.Text))
                {
                    this.grid.CancelEdit();
                }
                //this.Response.Write("<script>if(confirm('Confirm change this'+txt_Status.GetText()+' To'+cmb_Type.GetText()+'?')){alert('Sucess!');};</script>");
                person.UpdateBy       = HttpContext.Current.User.Identity.Name;
                person.UpdateDateTime = DateTime.Now;
                Manager.ORManager.StartTracking(person, Wilson.ORMapper.InitialState.Updated);
                Manager.ORManager.PersistChanges(person);
            }
            Session["PersonWhere" + txt_Status.Text] = "Id='" + person.Id + "' and Status='" + txt_Status.Text + "'";
            this.dsPerson.FilterExpression           = Session["PersonWhere" + txt_Status.Text].ToString();
            if (this.grid.GetRow(0) != null)
            {
                this.grid.StartEdit(0);
            }
            else
            {
                Session["PersonWhere" + txt_Status.Text] = "Id>0 and Status='" + txt_Status.Text + "'";
                this.dsPerson.FilterExpression           = Session["PersonWhere" + txt_Status.Text].ToString();
            }
        }
        catch (Exception ex) { throw new Exception(ex.Message + ex.StackTrace); }
    }