Exemplo n.º 1
0
    protected void TxtDate_TextChanged(object sender, EventArgs e)
    {
        try
        {
            if (TxtDate.Text.Length != 0)
            {
                StrSql        = new StringBuilder();
                StrSql.Length = 0;
                StrSql.AppendLine("Select D.Working_Date");
                StrSql.AppendLine("From DailyAttendance D");
                StrSql.AppendLine("Where D.EmpId=" + int.Parse(ddlEmployee.SelectedValue));
                StrSql.AppendLine("And D.Working_Date='" + ValueConvert.ConvertDate(TxtDate.Text.ToString()) + "'");

                dtTemp = new DataTable();
                dtTemp = SqlFunc.ExecuteDataTable(StrSql.ToString());
                if (dtTemp.Rows.Count != 0)
                {
                    LblMsg.Text   = "Attendance Entry Allready Done For " + TxtDate.Text.ToString() + ".";
                    TxtDate.Text  = "";
                    TxtDays.Text  = "";
                    TxtMonth.Text = "";
                    TxtDate.Focus();
                    return;
                }

                LblMsg.Text = "";
                GetDayMonth();
                TxtInTime.Focus();
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Exemplo n.º 2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["UserName"] == null)
            {
                Response.Redirect("FrmLogin.aspx");
            }

            BD.BindActi(DdlActivity, Session["BRCD"].ToString());
            TxtDate.Text = Session["EntryDate"].ToString();
            TxtDate.Focus();
        }
    }
 protected void TxtTPRD_TextChanged(object sender, EventArgs e)
 {
     try
     {
         string[] TD = BD.GetLoanGL(TxtTPRD.Text, Session["BRCD"].ToString()).Split('_');
         if (TD.Length > 1)
         {
         }
         TXtTPRDName.Text = TD[0].ToString();
         TxtDate.Focus();
     }
     catch (Exception Ex)
     {
         ExceptionLogging.SendErrorToText(Ex);
     }
 }
Exemplo n.º 4
0
    protected void ddlEmployee_SelectedIndexChanged(object sender, EventArgs e)
    {
        try
        {
            TxtOffFTime.Text = "";
            TxtOffTTime.Text = "";
            TxtOffHours.Text = "";

            if (ddlEmployee.SelectedValue != "0")
            {
                StrSql        = new StringBuilder();
                StrSql.Length = 0;
                StrSql.AppendLine("Select FJobTime,TJobTime");
                StrSql.AppendLine(",Abs(CAST(REPLACE(FJobTime,':','.') As Numeric(5,2))-");
                StrSql.AppendLine(" CAST(REPLACE(TJobTime,':','.') As Numeric(5,2))) As TotHours");
                StrSql.AppendLine("From Emp_Mast ");
                StrSql.AppendLine("Where Id=" + int.Parse(ddlEmployee.SelectedValue));

                dtTemp = new DataTable();
                dtTemp = SqlFunc.ExecuteDataTable(StrSql.ToString());

                if (dtTemp.Rows.Count != 0)
                {
                    TxtOffFTime.Text = dtTemp.Rows[0]["FJobTime"].ToString();
                    TxtOffTTime.Text = dtTemp.Rows[0]["TJobTIme"].ToString();
                    TxtOffHours.Text = dtTemp.Rows[0]["TotHours"].ToString();

                    TxtInTime.Text  = TxtOffFTime.Text;
                    TxtOutTime.Text = TxtOffTTime.Text;
                    GetTotTime();
                    TxtDate.Focus();
                }
            }
        }
        catch (Exception ex)
        {
            Response.Write(ex.ToString());
        }
    }
Exemplo n.º 5
0
    //protected void GridInOut_SelectedIndexChanged(object sender, EventArgs e)
    //{
    //    try
    //    {
    //        HidFldId.Value = GridInOut.DataKeys[GridInOut.SelectedRow.RowIndex].Value.ToString();

    //        StrSql = new StringBuilder();
    //        StrSql.Length = 0;

    //        StrSql = new StringBuilder();
    //        StrSql.Length = 0;
    //        StrSql.AppendLine("Select D.Id,D.EmpId");
    //        StrSql.AppendLine(",D.OffiFTime,D.OffiTTime,D.OffiHours");
    //        StrSql.AppendLine(",Convert(Varchar(10),D.Working_Date,103) As Working_Date,D.Working_Days,D.Working_Month");
    //        StrSql.AppendLine(",D.InTime,D.OutTime,D.TotWork_Hours");
    //        StrSql.AppendLine(",D.OverTime,D.LessTime");
    //        StrSql.AppendLine(",D.Reason,D.Remark");
    //        StrSql.AppendLine("From DailyAttendance D");
    //        StrSql.AppendLine("Where D.Id=" + int.Parse(HidFldId.Value));

    //        dtTemp = new DataTable();
    //        dtTemp = SqlFunc.ExecuteDataTable(StrSql.ToString());

    //        if (dtTemp.Rows.Count == 0)
    //        {
    //            LblMsg.Text = "Data not found";
    //            return;
    //        }

    //        ddlEmployee.Items.Clear();
    //        ddlEmployee.DataSource = BLayer.FillEmp("");
    //        ddlEmployee.DataValueField = "EmpId";
    //        ddlEmployee.DataTextField = "EmpName";
    //        ddlEmployee.DataBind();
    //        ddlEmployee.Items.Insert(0, new ListItem("--Select Employee--", "0"));

    //        if (dtTemp.Rows[0]["EmpId"].ToString() != "")
    //        {
    //            ddlEmployee.SelectedValue = dtTemp.Rows[0]["EmpId"].ToString();
    //        }

    //        TxtOffFTime.Text = dtTemp.Rows[0]["OffiFTime"].ToString();
    //        TxtOffTTime.Text = dtTemp.Rows[0]["OffiTTime"].ToString();
    //        TxtOffHours.Text = dtTemp.Rows[0]["OffiHours"].ToString();
    //        TxtDate.Text = dtTemp.Rows[0]["Working_Date"].ToString();
    //        TxtDays.Text = dtTemp.Rows[0]["Working_Days"].ToString();
    //        TxtMonth.Text = dtTemp.Rows[0]["Working_Month"].ToString();
    //        TxtInTime.Text = dtTemp.Rows[0]["InTime"].ToString();
    //        TxtOutTime.Text = dtTemp.Rows[0]["OutTime"].ToString();
    //        TxtTotWrkHours.Text = dtTemp.Rows[0]["TotWork_Hours"].ToString();
    //        TxtOverTime.Text = dtTemp.Rows[0]["OverTime"].ToString();
    //        TxtLessTime.Text = dtTemp.Rows[0]["LessTime"].ToString();
    //        TxtReason.Text = dtTemp.Rows[0]["Reason"].ToString();
    //        TxtRemark.Text = dtTemp.Rows[0]["Remark"].ToString();

    //        ddlEmployee.Enabled = false;

    //        // Move to Edit Tab
    //        MyMenu.Items[0].ImageUrl = "~/Images/ViewDisable.jpg";
    //        MyMenu.Items[1].ImageUrl = "~/Images/NewOrEditEnable.jpg";
    //        MyMenu.Items[1].Selected = true;
    //        MyMultiView.ActiveViewIndex = 1;
    //    }
    //    catch (Exception ex)
    //    {
    //        Response.Write(ex.ToString());
    //    }
    //}

    protected void BtnSave_Click(object sender, EventArgs e)
    {
        try
        {
            if (ddlEmployee.SelectedValue == "0")
            {
                //LblMsg.Text = "Employee Name Is Blank, Enter Valid Name....";
                ddlEmployee.Focus();
                return;
            }

            if (TxtDate.Text.Length == 0)
            {
                //LblMsg.Text = "Date Is Blank, Enter Valid Date....";
                TxtDate.Focus();
                return;
            }

            if (TxtInTime.Text.Length == 0)
            {
                //LblMsg.Text = "In Time Is Blank, Enter Valid Time....";
                TxtInTime.Focus();
                return;
            }

            string[] TotWrkHours = TxtTotWrkHours.Text.Split('.');
            int      WrkH        = ValueConvert.ValInt16(TotWrkHours[0].ToString());

            if (WrkH < 5 && TxtReason.Text.Length == 0)
            {
                LblMsg.Text = "Give Valid Reason, Because Working Hours Is Less Then 5.00...";
                TxtReason.Focus();
                return;
            }

            LblMsg.Text = "";

            StrSql        = new StringBuilder();
            StrSql.Length = 0;

            if (HidFldId.Value.Length == 0)
            {
                StrSql.AppendLine("Insert Into DailyAttendance");
                StrSql.AppendLine("(EmpId");
                StrSql.AppendLine(",OffiFTime");
                StrSql.AppendLine(",OffiTTime");
                StrSql.AppendLine(",OffiHours");
                StrSql.AppendLine(",Working_Date");
                StrSql.AppendLine(",Working_Days");
                StrSql.AppendLine(",Working_Month");
                StrSql.AppendLine(",InTime");
                StrSql.AppendLine(",OutTime");
                StrSql.AppendLine(",TotWork_Hours");
                StrSql.AppendLine(",OverTime");
                StrSql.AppendLine(",LessTime");
                StrSql.AppendLine(",Reason");
                StrSql.AppendLine(",Remark");
                StrSql.AppendLine(",Entry_Date");
                StrSql.AppendLine(",Entry_Time");
                StrSql.AppendLine(",Entry_UID");
                StrSql.AppendLine(",UPDFLAG");
                StrSql.AppendLine(")");
                StrSql.AppendLine("Values");
                StrSql.AppendLine("(@EmpId");
                StrSql.AppendLine(",@OffiFTime");
                StrSql.AppendLine(",@OffiTTime");
                StrSql.AppendLine(",@OffiHours");
                StrSql.AppendLine(",@Working_Date");
                StrSql.AppendLine(",@Working_Days");
                StrSql.AppendLine(",@Working_Month");
                StrSql.AppendLine(",@InTime");
                StrSql.AppendLine(",@OutTime");
                StrSql.AppendLine(",@TotWork_Hours");
                StrSql.AppendLine(",@OverTime");
                StrSql.AppendLine(",@LessTime");
                StrSql.AppendLine(",@Reason");
                StrSql.AppendLine(",@Remark");
                StrSql.AppendLine(",GetDate()");
                StrSql.AppendLine(",Convert(VarChar,GetDate(),108)");
                StrSql.AppendLine(",@Entry_UID");
                StrSql.AppendLine(",0");
                StrSql.AppendLine(")");
            }
            else
            {
                StrSql.AppendLine("Update DailyAttendance");
                StrSql.AppendLine("Set OffiFTime=@OffiFTime");
                StrSql.AppendLine(",OffiTTime=@OffiTTime");
                StrSql.AppendLine(",OffiHours=@OffiHours");
                StrSql.AppendLine(",Working_Date=@Working_Date");
                StrSql.AppendLine(",Working_Days=@Working_Days");
                StrSql.AppendLine(",Working_Month=@Working_Month");
                StrSql.AppendLine(",InTime=@InTime");
                StrSql.AppendLine(",OutTime=@OutTime");
                StrSql.AppendLine(",TotWork_Hours=@TotWork_Hours");
                StrSql.AppendLine(",OverTime=@OverTime");
                StrSql.AppendLine(",LessTime=@LessTime");
                StrSql.AppendLine(",Reason=@Reason");
                StrSql.AppendLine(",Remark=@Remark");
                StrSql.AppendLine(",MEntry_Date=GetDate(),MEntry_Time=Convert(Varchar,GetDate(),108)");
                StrSql.AppendLine(",MEntry_UID=@Entry_UID");
                StrSql.AppendLine(",UPDFLAG=IsNull(UPDFlag,0)+1");
                StrSql.AppendLine("Where Id=@Id And EmpId=@EmpId");
            }

            Cmd = new SqlCommand(StrSql.ToString(), SqlFunc.gConn);

            if (ddlEmployee.SelectedValue != "0")
            {
                Cmd.Parameters.AddWithValue("@EmpId", ddlEmployee.SelectedValue);
            }
            else
            {
                Cmd.Parameters.AddWithValue("@EmpId", DBNull.Value);
            }

            Cmd.Parameters.AddWithValue("@OffiFTime", TxtOffFTime.Text);
            Cmd.Parameters.AddWithValue("@OffiTTime", TxtOffTTime.Text);
            Cmd.Parameters.AddWithValue("@OffiHours", TxtOffHours.Text);

            if (TxtDate.Text.Length != 0)
            {
                Cmd.Parameters.AddWithValue("@Working_Date", ValueConvert.ConvertDate(TxtDate.Text));
            }
            else
            {
                Cmd.Parameters.AddWithValue("@Working_Date", DBNull.Value);
            }

            Cmd.Parameters.AddWithValue("@Working_Days", TxtDays.Text);
            Cmd.Parameters.AddWithValue("@Working_Month", TxtMonth.Text);
            Cmd.Parameters.AddWithValue("@InTime", TxtInTime.Text);
            Cmd.Parameters.AddWithValue("@OutTime", TxtOutTime.Text);
            Cmd.Parameters.AddWithValue("@TotWork_Hours", TxtTotWrkHours.Text);
            Cmd.Parameters.AddWithValue("@OverTime", TxtOverTime.Text);
            Cmd.Parameters.AddWithValue("@LessTime", TxtLessTime.Text);
            Cmd.Parameters.AddWithValue("@Reason", TxtReason.Text);
            Cmd.Parameters.AddWithValue("@Remark", TxtRemark.Text);

            Cmd.Parameters.AddWithValue("@Entry_UID", HidFldUID.Value.ToString());

            if (HidFldId.Value.Length == 0)
            {
                SqlFunc.ExecuteNonQuery(Cmd);
                LblMsg.Text = "Entry added successfully";
            }
            else
            {
                Cmd.Parameters.AddWithValue("@ID", HidFldId.Value.ToString());

                SqlFunc.ExecuteNonQuery(Cmd);
                LblMsg.Text = "Entry updated successfully";
            }

            FillGrid();

            ClearAll();

            //// Move to View Tab
            //MyMenu.Items[0].Selected = true;
            //MyMenu.Items[0].ImageUrl = "~/Images/ViewEnable.jpg";
            //MyMultiView.ActiveViewIndex = 0;
            //MyMenu.Items[1].ImageUrl = "~/Images/NewOrEditDisable.jpg";

            ddlEmployee.Focus();
        }
        catch (Exception ex)
        {
            Response.Write(ex);
        }
    }
Exemplo n.º 6
0
        private void BtnOk_Click(object sender, EventArgs e)
        {
            if (ClsGlobal.CheckDateInsideCompanyPeriod(Convert.ToDateTime(TxtDate.Text)) == 1)
            {
                ClsGlobal.DateMitiRangeMsg();
                return;
            }

            if (string.IsNullOrEmpty(TxtVoucherNo.Text.Trim()))
            {
                MessageBox.Show("Voucher number cannot be left blank.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtVoucherNo.Focus();
                return;
            }
            if (TxtMiti.Text == "  /  /")
            {
                MessageBox.Show("Miti cannot be left blank.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtMiti.Focus();
                return;
            }

            if (TxtDate.Text == "  /  /")
            {
                MessageBox.Show("Date cannot be left blank.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                TxtDate.Focus();
                return;
            }

            if (Grid.Rows.Count <= 0)
            {
                MessageBox.Show("Invoice details not found.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Grid.Focus();
                return;
            }

            if (Grid.Rows.Count == 1 && Grid.Rows[0].Cells["Particular"].Value == null)
            {
                MessageBox.Show("Invoice details not found.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                BtnOk.Enabled = false;
                Grid.Focus();
                return;
            }

            _objPurchaseIndent.Model.EntryFromProject = "Normal";
            _objPurchaseIndent.Model.Gadget           = "Desktop";

            _objPurchaseIndent.Model.VDate       = Convert.ToDateTime(TxtDate.Text);
            _objPurchaseIndent.Model.Tag         = _Tag;
            _objPurchaseIndent.Model.VoucherNo   = TxtVoucherNo.Text.Trim();
            _objPurchaseIndent.Model.VTime       = _objDate.GetServerDateTime();
            _objPurchaseIndent.Model.VMiti       = TxtMiti.Text;
            _objPurchaseIndent.Model.RequestedBy = txtRequestedBy.Text;
            if (!string.IsNullOrEmpty(TxtDepartment.Text))
            {
                string[] dept = TxtDepartment.Tag.ToString().Split('|');
                _objPurchaseIndent.Model.DepartmentId1 = ((dept[0].ToString() == "") ? 0 : Convert.ToInt32(dept[0].ToString()));
                _objPurchaseIndent.Model.DepartmentId2 = ((dept[1].ToString() == "") ? 0 : Convert.ToInt32(dept[1].ToString()));
                _objPurchaseIndent.Model.DepartmentId3 = ((dept[2].ToString() == "") ? 0 : Convert.ToInt32(dept[2].ToString()));
                _objPurchaseIndent.Model.DepartmentId4 = ((dept[3].ToString() == "") ? 0 : Convert.ToInt32(dept[3].ToString()));
            }
            _objPurchaseIndent.Model.Remarks       = TxtRemarks.Text;
            _objPurchaseIndent.Model.BranchId      = ClsGlobal.BranchId;
            _objPurchaseIndent.Model.CompanyUnitId = ClsGlobal.CompanyUnitId;

            PurchaseIndentDetailsViewModel _PurchaseIndentDetails = null;
            int dc = Grid.Rows.Count;

            foreach (DataGridViewRow ro in Grid.Rows)
            {
                if (ro.Cells["Particular"].Value != null)
                {
                    _PurchaseIndentDetails = new PurchaseIndentDetailsViewModel
                    {
                        VoucherNo = _objPurchaseIndent.Model.VoucherNo,
                        Sno       = Grid.Rows.IndexOf(ro) + 1,
                        ProductId = Convert.ToInt32(ro.Cells["ProductId"].Value.ToString())
                    };

                    if (ro.Cells["AltQty"].Value != null)
                    {
                        decimal.TryParse(ro.Cells["AltQty"].Value.ToString().Trim(), out decimal _AltQty);
                        _PurchaseIndentDetails.AltQty = _AltQty;
                    }
                    else
                    {
                        _PurchaseIndentDetails.AltQty = 0;
                    }

                    if (ro.Cells["AltQty"].Value != null)
                    {
                        _PurchaseIndentDetails.ProductAltUnitId = !string.IsNullOrEmpty(ro.Cells["ProductAltUnitId"].Value.ToString()) ? Convert.ToInt32(ro.Cells["ProductAltUnitId"].Value.ToString()) : 0;
                    }

                    _PurchaseIndentDetails.Qty = ro.Cells["Qty"].Value != null?Convert.ToDecimal(ro.Cells["Qty"].Value.ToString().Trim()) : 0;

                    if (ro.Cells["ProductUnitId"].Value != null)
                    {
                        _PurchaseIndentDetails.ProductUnitId = string.IsNullOrEmpty(ro.Cells["ProductUnitId"].Value.ToString()) ? 0 : Convert.ToInt32(ro.Cells["ProductUnitId"].Value.ToString());
                    }
                    else
                    {
                        _PurchaseIndentDetails.ProductUnitId = 0;
                    }

                    _PurchaseIndentDetails.ConversionRatio = ro.Cells["QtyConversion"].Value != null?Convert.ToDecimal(ro.Cells["QtyConversion"].Value.ToString().Trim()) : 0;

                    _PurchaseIndentDetails.Narration = ro.Cells["Narration"].Value.ToString();

                    _objPurchaseIndent.ModelDetails.Add(_PurchaseIndentDetails);
                }
            }

            _objPurchaseIndent.Model.DocId = Convert.ToInt32(TxtVoucherNo.Tag.ToString());
            string output = "";

            if (_Tag == "DELETE")
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure want to Delete Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }
            }

            if (_Tag == "NEW")
            {
                if (ClsGlobal.ConfirmSave == 1)
                {
                    DialogResult dialogResult = MessageBox.Show("Are you sure want to Save New Record..??", "Close Form", MessageBoxButtons.YesNo, MessageBoxIcon.Error);
                    if (dialogResult == DialogResult.Yes)
                    {
                        output = _objPurchaseIndent.SavePurchaseIndent();
                    }
                }
                else
                {
                    output = _objPurchaseIndent.SavePurchaseIndent();
                }
            }
            else
            {
                output = _objPurchaseIndent.SavePurchaseIndent();
            }

            if (string.IsNullOrEmpty(output))
            {
                MessageBox.Show("Error occurred during data submission.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                if (_Tag == "NEW")
                {
                    MessageBox.Show("Voucher number : " + TxtVoucherNo.Text + " has been generated.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (_Tag == "EDIT")
                {
                    MessageBox.Show("Voucher number : " + TxtVoucherNo.Text + " has been updated.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else if (_Tag == "DELETE")
                {
                    MessageBox.Show("Voucher number : " + TxtVoucherNo.Text + " has been deleted.", "Mr Solution", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }

                ClearFld();
                if (this._Tag == "NEW")
                {
                    _DocId         = Convert.ToInt32(TxtVoucherNo.Tag.ToString());
                    BtnNew.Enabled = true;
                    BtnNew.PerformClick();
                }
                else if (this._Tag == "EDIT")
                {
                    BtnEdit.Enabled = true;
                    BtnEdit.PerformClick();
                }
                else if (this._Tag == "DELETE")
                {
                    BtnDelete.Enabled = true;
                    BtnDelete.PerformClick();
                }
            }
        }