示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int    year = Convert.ToInt32(TxtYear.Text);
                string msg  = "";

                if (year % 4 == 0 && year % 100 != 0)
                {
                    msg = year + "是閏年";
                }
                else if (year % 400 == 0 && year % 100 == 0)
                {
                    msg = year + "是閏年";
                }
                else
                {
                    //(year % 400 != 0 && year % 100 == 0) || (year%4!=0)
                    msg = year + "是平年";
                }

                LblAns.Text = msg;
            }
            catch
            {
                MessageBox.Show("請輸入年分", "注意");
                TxtYear.Clear();
                TxtYear.Focus();
            }
        }
    protected void btnSaveLeave_Click(object sender, EventArgs e)
    {
        int b = 0;

        if (TxtClaimName.Text == "")
        {
            DisplayMessage("Enter Claim Name");
            TxtClaimName.Focus();
            return;
        }
        if (DdlValueType.SelectedIndex == 0)
        {
            DisplayMessage("Select Value Type");
            DdlValueType.Focus();
            return;
        }
        if (txtCalValue.Text == "")
        {
            DisplayMessage("Enter Value");
            txtCalValue.Focus();
            return;
        }
        if (ddlMonth.SelectedIndex == 0)
        {
            DisplayMessage("Select Month");
            ddlMonth.Focus();
            return;
        }
        if (TxtYear.Text == "")
        {
            DisplayMessage("Enter Year");
            TxtYear.Focus();
            return;
        }
        b = ObjClaim.Insert_In_Pay_Employee_ClaimRequest(Session["CompId"].ToString(), HidEmpId.Value, TxtClaimName.Text.Trim(), TxtClaimDiscription.Text, DdlValueType.SelectedValue, txtCalValue.Text, DateTime.Now.ToString(), "Pending", DateTime.Now.ToString(), ddlMonth.SelectedValue, TxtYear.Text, "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());

        if (b != 0)
        {
            DisplayMessage("Record Saved");
            Reset();
        }
    }
示例#3
0
    protected void btnSaveLeave_Click(object sender, EventArgs e)
    {
        int b = 0;



        string TransNo = string.Empty;


        if (rbtnGroup.Checked)
        {
            string GroupIds = string.Empty;
            string EmpIds   = string.Empty;



            for (int i = 0; i < lbxGroup.Items.Count; i++)
            {
                if (lbxGroup.Items[i].Selected)
                {
                    GroupIds += lbxGroup.Items[i].Value + ",";
                }
            }



            if (GroupIds != "")
            {
                DataTable dtEmp = objEmp.GetEmployeeMaster(Session["CompId"].ToString());

                dtEmp = new DataView(dtEmp, "Brand_Id='" + Session["BrandId"].ToString() + "'  and Location_Id='" + Session["LocId"].ToString() + "'", "", DataViewRowState.CurrentRows).ToTable();
                DataTable dtEmpInGroup = objGroupEmp.GetGroup_EmployeeById(Session["CompId"].ToString());

                dtEmpInGroup = new DataView(dtEmpInGroup, "Group_Id in(" + GroupIds.Substring(0, GroupIds.Length - 1) + ")", "", DataViewRowState.CurrentRows).ToTable();

                for (int i = 0; i < dtEmpInGroup.Rows.Count; i++)
                {
                    if (!EmpIds.Split(',').Contains(dtEmpInGroup.Rows[i]["Emp_Id"].ToString()))
                    {
                        EmpIds += dtEmpInGroup.Rows[i]["Emp_Id"].ToString() + ",";
                    }
                }
            }
            else
            {
                DisplayMessage("Select Group First");
            }


            foreach (string str in EmpIds.Split(','))
            {
                if (str != "")
                {
                    DataTable dtempmonth = new DataTable();
                    dtempmonth = objPayEmpMonth.GetAllRecordPostedEmpMonth(str, ddlMonth.SelectedIndex.ToString(), TxtYear.Text.ToString());
                    if (dtempmonth.Rows.Count > 0)
                    {
                        DisplayMessage("Payroll Already Generated");
                        return;
                    }
                    else
                    {
                        b = ObjClaim.Insert_In_Pay_Employee_Claim(Session["CompId"].ToString(), str, TxtClaimName.Text.Trim(), TxtClaimDiscription.Text, DdlValueType.SelectedValue, txtCalValue.Text, DateTime.Now.ToString(), "Approved", DateTime.Now.ToString(), ddlMonth.SelectedValue, TxtYear.Text, "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());
                    }
                }
            }
        }

        else
        {
            if (lblSelectRecd.Text == "")
            {
                DisplayMessage("Select Employee First");
                return;
            }
            if (TxtClaimName.Text == "")
            {
                DisplayMessage("Enter Claim Name");
                TxtClaimName.Focus();
                return;
            }
            if (DdlValueType.SelectedIndex == 0)
            {
                DisplayMessage("Select Value Type");
                DdlValueType.Focus();
                return;
            }
            if (txtCalValue.Text == "")
            {
                DisplayMessage("Enter Value");
                txtCalValue.Focus();
                return;
            }
            if (ddlMonth.SelectedIndex == 0)
            {
                DisplayMessage("Select Month");
                ddlMonth.Focus();
                return;
            }
            if (TxtYear.Text == "")
            {
                DisplayMessage("Enter Year");
                TxtYear.Focus();
                return;
            }

            foreach (string str in lblSelectRecd.Text.Split(','))
            {
                if (str != "")
                {
                    DataTable dtempmonth = new DataTable();
                    dtempmonth = objPayEmpMonth.GetAllRecordPostedEmpMonth(str, ddlMonth.SelectedIndex.ToString(), TxtYear.Text.ToString());
                    if (dtempmonth.Rows.Count > 0)
                    {
                        DisplayMessage("Payroll Already Generated");
                        return;
                    }
                    else
                    {
                        b = ObjClaim.Insert_In_Pay_Employee_Claim(Session["CompId"].ToString(), str, TxtClaimName.Text.Trim(), TxtClaimDiscription.Text, DdlValueType.SelectedValue, txtCalValue.Text, DateTime.Now.ToString(), "Approved", DateTime.Now.ToString(), ddlMonth.SelectedValue, TxtYear.Text, "", "", "", "", "", true.ToString(), DateTime.Now.ToString(), true.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString(), Session["UserId"].ToString(), DateTime.Now.ToString());
                    }
                }
            }
        }
        if (b != 0)
        {
            DisplayMessage("Record Saved");
            rbtnEmp.Checked   = true;
            rbtnGroup.Checked = false;

            EmpGroup_CheckedChanged(null, null);
            Reset();
        }
        else
        {
            DisplayMessage("Record Not Saved");
        }
    }