/*
  * Op=1 Insert Data
  * Op=2 Delete Data
  * Op=3 Add Indent
  * Op=4 View data by Site
  * Op=5 View Data by Machine
  */
 public DataSet MachineDamage(clsMachineDamage obj)
 {
     try
     {
         connect();
         SqlParameter[] param = new SqlParameter[8];
         param[0] = new SqlParameter("@ID", obj._ID);
         param[1] = new SqlParameter("@SiteID", obj._SiteID);
         param[2] = new SqlParameter("@SiteMachineID", obj._SiteMachineID);
         param[3] = new SqlParameter("@EntryDate1", obj._EntryDate1);
         param[4] = new SqlParameter("@EntryDate2", obj._EntryDate2);
         param[5] = new SqlParameter("@Remarks", obj._Remarks);
         param[6] = new SqlParameter("@IndentID", obj._IndentID);
         param[7] = new SqlParameter("@Op", obj._Op);
         DataSet ds = SqlHelper.ExecuteDataset(co, "procMachineDamage", param);
         return(ds);
     }
     catch
     {
         return(null);
     }
     finally
     {
         co.Close();
     }
 }
示例#2
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     foreach (GridViewRow dr in grd.Rows)
     {
         HiddenField hdSiteMachineID = dr.FindControl("hdSiteMachineID") as HiddenField;
         HiddenField hdIndentID      = dr.FindControl("hdIndentID") as HiddenField;
         TextBox     txtRemark       = dr.FindControl("txtRemark") as TextBox;
         CheckBox    chkBreak        = dr.FindControl("chkBreak") as CheckBox;
         if (chkBreak.Checked == true)
         {
             clsMachineDamage obj = new clsMachineDamage();
             obj.SiteID        = Convert.ToInt32(ddlSite.SelectedValue);
             obj.SiteMachineID = Convert.ToInt32(hdSiteMachineID.Value);
             try { obj.EntryDate1 = Convert.ToDateTime(txtDate.Text).ToShortDateString(); }
             catch { obj.EntryDate1 = DateTime.Today.ToShortDateString(); }
             obj.Remarks = txtRemark.Text;
             try { obj.IndentID = Convert.ToInt32(hdIndentID.Value); }
             catch { obj.IndentID = 0; }
             obj.Op = 1;
             obj.MachineDamage(obj);
             clsSiteMachines obSM = new clsSiteMachines();
             obSM.Op = 2;
             try { obSM.UpdateDate = Convert.ToDateTime(txtDate.Text).ToShortDateString(); }
             catch { }
             obSM.Status = 3;
             obSM.ID     = Convert.ToInt32(hdSiteMachineID.Value);
             obSM.SiteMachines(obSM);
         }
     }
     pnlExisting.Visible = true;
     pnlNewEntry.Visible = false;
     LoadDamage();
 }
示例#3
0
    protected void grdDamage_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        clsMachineDamage obj = new clsMachineDamage();

        obj.Op = 2;
        obj.ID = Convert.ToInt32(grdDamage.DataKeys[e.RowIndex].Value);
        obj.MachineDamage(obj);
        LoadDamage();
    }
    public void GetBreakdownByMachine(int SiteMachineID)
    {
        clsMachineDamage obj = new clsMachineDamage();

        obj.SiteMachineID = SiteMachineID;
        obj.Op            = 5;
        DataTable dt = obj.MachineDamage(obj).Tables[0];

        Context.Response.Write(JsonConvert.SerializeObject(dt));
    }
    public void GetMachineDamageBySiteAndDate(string EntryDate1, string EntryDate2, int SiteID)
    {
        clsMachineDamage obj = new clsMachineDamage();

        obj.EntryDate1 = EntryDate1;
        obj.EntryDate2 = EntryDate2;
        obj.SiteID     = SiteID;
        obj.Op         = 7;
        DataTable dt = obj.MachineDamage(obj).Tables[0];

        Context.Response.Write(JsonConvert.SerializeObject(dt));
    }
    public void SaveMachineDamage(int SiteID, int SiteMachineID, string EntryDate, string Remarks, int IndentID)
    {
        clsMachineDamage obj = new clsMachineDamage();

        obj.SiteID        = SiteID;
        obj.SiteMachineID = SiteMachineID;
        obj.EntryDate1    = EntryDate;
        obj.Remarks       = Remarks;
        obj.IndentID      = IndentID;
        obj.MachineDamage(obj);
        Context.Response.Write(JsonConvert.SerializeObject("Saved"));
    }
示例#7
0
    protected void btnUpdate_Click(object sender, EventArgs e)
    {
        clsMachineDamage obj = new clsMachineDamage();

        obj.IndentID = Convert.ToInt32(hdEIndentID.Value);
        obj.ID       = Convert.ToInt32(grdDamage.DataKeys[grdDamage.SelectedIndex].Value);
        obj.Op       = 3;
        obj.MachineDamage(obj);

        grdDamage.SelectedIndex = -1;
        pnlUpdate.Visible       = false;
        LoadDamage();
    }
示例#8
0
    void LoadDamage()
    {
        clsMachineDamage obj = new clsMachineDamage();
        LiteralControl   lc;

        obj.SiteID = Convert.ToInt32(ddlSite.SelectedValue);
        obj.Op     = 4;
        DataTable dt     = obj.MachineDamage(obj).Tables[0];
        DataTable dtMain = new DataTable();

        foreach (DataColumn dc in dt.Columns)
        {
            dtMain.Columns.Add(dc.ColumnName);
        }
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            dtMain.Rows.Add();
            for (int j = 0; j < dt.Columns.Count; j++)
            {
                if (dt.Columns[j].ColumnName != "EntryDate")
                {
                    dtMain.Rows[i][j] = dt.Rows[i][j].ToString();
                }
                else
                {
                    dtMain.Rows[i][j] = Convert.ToDateTime(dt.Rows[i][j]).ToShortDateString();
                }
            }
        }
        dt = dtMain;
        grdDamage.DataSource = dt;
        grdDamage.DataBind();
        foreach (GridViewRow dr in grdDamage.Rows)
        {
            lc = new LiteralControl();
            if (dt.Rows[dr.RowIndex]["IndentID"] != "" && Convert.ToInt32(dt.Rows[dr.RowIndex]["IndentID"]) != 0)
            {
                lc.Text = "<a href='ViewIndent.aspx?ID=" + dt.Rows[dr.RowIndex]["IndentID"].ToString() + "' target='_blank'>View Indent</a>";
                LinkButton LinkButton1 = dr.FindControl("LinkButton1") as LinkButton;
                LinkButton1.Text = "Change Indent";
            }
            else
            {
                lc.Text = "<a href='CreateIndent.aspx' target='_blank'>Create New Indent</a>";
            }
            dr.Cells[4].Controls.Add(lc);
        }
    }
    void LoadData()
    {
        clsMachineDamage obj = new clsMachineDamage();

        obj.SiteID        = Convert.ToInt32(ddlSite.SelectedValue);
        obj.SiteMachineID = Convert.ToInt32(ddlMachine.SelectedValue);
        try { obj.EntryDate1 = Convert.ToDateTime(txtDateFrom.Text).ToShortDateString(); }
        catch { }
        try { obj.EntryDate2 = Convert.ToDateTime(txtDateTo.Text).ToShortDateString(); }
        catch { }
        if (rdType.SelectedValue == "1")
        {
            obj.Op = 7;
        }
        else if (rdType.SelectedValue == "2")
        {
            obj.Op = 6;
        }
        DataTable      dt = obj.MachineDamage(obj).Tables[0];
        LiteralControl lc = new LiteralControl();

        lc.Text = "<table width='100%'>";
        lc.Text = lc.Text + "<tr><td><h5>T K ENGINEERING CONSORTIUM PVT. LTD.</h5></td></tr>";
        lc.Text = lc.Text + "<tr><td><h6>Site: " + ddlSite.SelectedItem.Text + "</h6></td></tr>";
        if (rdType.SelectedValue == "2")
        {
            lc.Text = lc.Text + "<tr><td><h5>Log No/Machine: " + ddlMachine.SelectedItem.Text + "</h5></td></tr>";
        }
        lc.Text = lc.Text + "</table>";
        lc.Text = lc.Text + "<table width='100%' border='1' style='font-size:8;'>";
        lc.Text = lc.Text + "<tr>";
        if (rdType.SelectedValue == "1")
        {
            lc.Text = lc.Text + "<td><b>Log No/Machine</b></td>";
        }
        lc.Text = lc.Text + "<td><b>Date</b></td><td><b>Remarks</b></td><td><b>Indent</b></td></tr>";
        foreach (DataRow dr in dt.Rows)
        {
            if (rdType.SelectedValue == "1")
            {
                lc.Text = lc.Text + "<td>" + dr["Machine"] + "</td>";
            }
            lc.Text = lc.Text + "<td>" + Convert.ToDateTime(dr["EntryDate"]).ToShortDateString() + "</td><td>" + dr["Remarks"] + "</td><td>" + dr["Indent"] + "</td></tr>";
        }
        lc.Text = lc.Text + "</table>";
        pnlDetail.Controls.Add(lc);
    }
示例#10
0
    void LoadData()
    {
        /*Site Machine Detail*/
        clsSiteMachines obSM = new clsSiteMachines();

        obSM.ID = Convert.ToInt32(ddlMachine.SelectedValue);
        obSM.Op = 5;
        DataTable dtSM = obSM.SiteMachines(obSM).Tables[0];
        /*ID,Site,MachineID,Machine,SerialNo,AddedOn,Status,UpdateDate,a.UsageUnit,a.ThesisNo,a.EngineNo,a.RegistrationNo*/
        /*Machine Damage History*/
        clsMachineDamage obMD = new clsMachineDamage();

        obMD.SiteMachineID = Convert.ToInt32(ddlMachine.SelectedValue);
        try { obMD.EntryDate1 = Convert.ToDateTime(txtDateFrom.Text).ToShortDateString(); }
        catch { }
        try { obMD.EntryDate2 = Convert.ToDateTime(txtDateTo.Text).ToShortDateString(); }
        catch { }
        obMD.Op = 6;
        DataTable dtMD = obMD.MachineDamage(obMD).Tables[0];
        /*ID, SiteID,Site,SiteMachineID,Machine,EntryDate,Remarks,IndentID,Indent*/
        /*Machine Progress History*/
        clsMachineryUsage obMU = new clsMachineryUsage();

        obMU.Op            = 8;
        obMU.SiteID        = Convert.ToInt32(ddlSite.SelectedValue);
        obMU.SiteMachineID = Convert.ToInt32(ddlMachine.SelectedValue);
        try { obMU.EntryDate1 = Convert.ToDateTime(txtDateFrom.Text).ToShortDateString(); }
        catch { }
        try { obMU.EntryDate2 = Convert.ToDateTime(txtDateTo.Text).ToShortDateString(); }
        catch { }
        DataTable dtMU = obMU.MachineryUsage(obMU).Tables[0];

        obMU.Op = 14;
        DataTable dtFuel = obMU.MachineryUsage(obMU).Tables[0];

        obMU.Op = 13;
        DataTable dtBreakdown = obMU.MachineryUsage(obMU).Tables[0];

        /*ID,,EntryDate,Shift,ShiftText,SiteID,Site,SiteMachineID,Machine,OpenKMReading,CloseKMReading,TotalKMReading,OpenHRReading,CloseHRReading,TotalHRReading,OpenHSDReading,
         * CloseHSDReading,HSDIssue,TotalHSDReading,Breakdown,Idle,DriverName,Remarks,Status,EnteredBy*/
        /*Issue Slips*/
        clsSitePartIssue obSPI = new clsSitePartIssue();

        obSPI.Op = 7;
        try { obSPI.EntryDate1 = Convert.ToDateTime(txtDateFrom.Text).ToShortDateString(); }
        catch { }
        try { obSPI.EntryDate2 = Convert.ToDateTime(txtDateTo.Text).ToShortDateString(); }
        catch { }
        obSPI.SiteMachineID = Convert.ToInt32(ddlMachine.SelectedValue);
        DataTable dtSPI = obSPI.SitePartIssue(obSPI).Tables[0];
        /*ID,SiteID,Site,SiteMachineID,Machine,IssueDate,IssueType,Issue,Detail,Quantity,Rate,Total,Remarks*/
        /*Machine Transfer*/
        clsMachineTransfer obMT = new clsMachineTransfer();

        obMT.Op            = 8;
        obMT.SiteMachineID = Convert.ToInt32(ddlMachine.SelectedValue);
        DataTable dtMT      = obMT.MachineTransfer(obMT).Tables[0];
        DataTable dtMTFinal = new DataTable();

        dtMTFinal.Columns.Add("Site");
        dtMTFinal.Columns.Add("FromDate");
        dtMTFinal.Columns.Add("ToDate");
        if (dtMT.Rows.Count > 0)
        {
            dtMTFinal.Rows.Add();
            dtMTFinal.Rows[0]["Site"]     = dtMT.Rows[0]["SourceSite"];
            dtMTFinal.Rows[0]["FromDate"] = Convert.ToDateTime(dtMT.Rows[0]["AddedOn"]).ToShortDateString();
            dtMTFinal.Rows[0]["ToDate"]   = Convert.ToDateTime(dtMT.Rows[0]["StartDate"]).ToShortDateString();
            for (int i = 1; i < dtMT.Rows.Count; i++)
            {
                dtMTFinal.Rows.Add();
                dtMTFinal.Rows[i]["Site"]     = dtMT.Rows[i]["SourceSite"];
                dtMTFinal.Rows[i]["FromDate"] = Convert.ToDateTime(dtMTFinal.Rows[i - 1]["UpdatedDate"]).ToShortDateString();
                dtMTFinal.Rows[i]["ToDate"]   = Convert.ToDateTime(dtMTFinal.Rows[i]["StartDate"]).ToShortDateString();
            }
        }
        /*ID,SourceSiteID,AddedOn,SourceSite,DestinationSiteID,DestinationSite,SiteMachineID,StartDate,UpdateDate,UpdatedBy,Status,Remarks*/
        LiteralControl lc = new LiteralControl();

        lc.Text = "<h4>T K ENGINEERING CONSORTIUM PVT. LTD.</h4>";
        lc.Text = lc.Text + "<br><br><h5>Basic Detail:</h5>";
        lc.Text = lc.Text + "<table width='100%' style='font-size:8'>";
        lc.Text = lc.Text + "<tr><td>Site: " + dtSM.Rows[0]["Site"] + "</td><td>Machine: " + dtSM.Rows[0]["Machine"] + "</td><td>Log No: " + dtSM.Rows[0]["SerialNo"] + "</td><td>Registration No: " + dtSM.Rows[0]["RegistrationNo"] + "</td></tr>";
        lc.Text = lc.Text + "<tr><td>Engine No: " + dtSM.Rows[0]["EngineNo"] + "</td><td>Current Status: " + dtSM.Rows[0]["Status"] + "</td><td colspan='2'>Chessis No: " + dtSM.Rows[0]["ThesisNo"] + "</td></tr>";
        lc.Text = lc.Text + "</table>";

        lc.Text = lc.Text + "<h5>List of locations of the machine:</h5><br>";
        lc.Text = lc.Text + "<table width='100%' border='1' style='font-size:8'>";
        lc.Text = lc.Text + "<tr><td><b>From Date</b></td><td><b>To Date</b></td><td><b>Location</b></td></tr>";
        foreach (DataRow dr in dtMTFinal.Rows)
        {
            lc.Text = lc.Text + "<tr><td>" + dr["FromDate"] + "</td><td>" + dr["ToDate"] + "</b></td><td>" + dr["Site"] + "</td></tr>";
        }
        lc.Text = lc.Text + "</table>";
        lc.Text = lc.Text + "<h5>Fuel Issues</h5><br>";
        lc.Text = lc.Text + "<table width='100%' border='1' style='font-size:8'>";
        lc.Text = lc.Text + "<tr><td><b>Date</b></td><td><b>Site</b></td><td><b>Amount</b></td></tr>";
        foreach (DataRow dr in dtFuel.Rows)
        {
            lc.Text = lc.Text + "<tr><td>" + Convert.ToDateTime(dr["EntryDate"]).ToShortDateString() + "</td><td>" + dr["Site"] + "</td><td>" + Convert.ToInt32(dr["HSDIssue"]) + "</td></tr>";
        }
        lc.Text = lc.Text + "</table>";
        lc.Text = lc.Text + "<h5>Spare Part Issue:</h5><br>";
        //ID,SiteID,Site,SiteMachineID,Machine,IssueDate,IssueType,Issue,Detail,Quantity,Rate,Total,Remarks
        lc.Text = lc.Text + "<table width='100%' border='1' style='font-size:8'>";
        lc.Text = lc.Text + "<tr><td><b>Date</b></td><td><b>Site</b></td><td><b>Part No</b></td><td><b>Part Name</b></td><td><b>Quantity</b></td></tr>";
        foreach (DataRow dr in dtSPI.Rows)
        {
            if (Convert.ToInt32(dr["IssueType"]) == 2)
            {
                lc.Text = lc.Text + "<tr><td>" + Convert.ToDateTime(dr["IssueDate"]).ToShortDateString() + "</td><td>" + Convert.ToDateTime(dr["Site"]) + "</td><td>" + dr["PartNo"] + "</td><td>" + Convert.ToInt32(dr["PartName"]) + "</td><td>" + dr["Quantity"] + "</td></tr>";
            }
        }
        lc.Text = lc.Text + "</table>";
        lc.Text = lc.Text + "<h5>Breakdowns:</h5><br>";
        lc.Text = lc.Text + "<table width='100%' border='1' style='font-size:8'>";
        lc.Text = lc.Text + "<tr><td><b>Date</b></td><td><b>Remarks</b></td><td><b>Indent</b></td></tr>";
        foreach (DataRow dr in dtMD.Rows)
        {
            lc.Text = lc.Text + "<tr><td>" + Convert.ToDateTime(dr["EntryDate"]).ToShortDateString() + "</td><td>" + dr["Remarks"] + "</td><td>" + dr["Indent"] + "</td></tr>";
        }
        lc.Text = lc.Text + "</table>";
        lc.Text = lc.Text + "<h5>Daily Progress Report:</h5><br>";

        /*ID,EntryDate,Shift,ShiftText,SiteID,Site,SiteMachineID,Machine,OpenKMReading,CloseKMReading,TotalKMReading,OpenHRReading,CloseHRReading,TotalHRReading,OpenHSDReading,
         * CloseHSDReading,HSDIssue,TotalHSDReading,Breakdown,Idle,DriverName,Remarks,Status,EnteredBy*/
        lc.Text = lc.Text + "<table width='100%' border='1' style='font-size:6'>";
        lc.Text = lc.Text + "<tr><td><b>Site</b></td><td><b>Entry Date</b></td><td><b>Shift</b></td><td><b>Open KM Reading</b></td><td><b>Close KM Reading</b></td><td><b>Total KM Reading</b></td>";
        lc.Text = lc.Text + "<td><b>Open HR Reading</b></td><td><b>Close HR Reading</b></td><td><b>Total HR Reading</b></td><td><b>Open HSD Reading</b></td><td><b>Close HSD Reading</b></td>";
        lc.Text = lc.Text + "<td><b>HSD Issue</b></td><td><b>Total HSD Reading</b></td><td><b>Breakdown</b></td><td><b>Idle</b></td><td><b>Driver Name</b></td><td><b>Remarks</b></td>";
        foreach (DataRow dr in dtMU.Rows)
        {
            lc.Text = lc.Text + "<tr>";
            lc.Text = lc.Text + "<td>" + dr["Site"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["EntryDate"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["ShiftText"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["OpenKMReading"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["CloseKMReading"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["TotalKMReading"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["OpenHRReading"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["CloseHRReading"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["TotalHRReading"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["OpenHSDReading"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["CloseHSDReading"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["HSDIssue"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["TotalHSDReading"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["Breakdown"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["Idle"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["DriverName"] + "</td>";
            lc.Text = lc.Text + "<td>" + dr["Remarks"] + "</td>";
            lc.Text = lc.Text + "</tr>";
        }
        lc.Text = lc.Text + "</table>";

        pnlDetail.Controls.Add(lc);
    }
    public void GetMachineHistory(int SiteMachineID, string DateFrom, string DateTo, int SiteID)
    {
        DataTable[]     dt   = new DataTable[8];
        clsSiteMachines obSM = new clsSiteMachines();

        obSM.ID = SiteMachineID;
        obSM.Op = 5;
        DataTable dtSM = obSM.SiteMachines(obSM).Tables[0];

        dt[0] = dtSM;
        /*ID,Site,MachineID,Machine,SerialNo,AddedOn,Status,UpdateDate,a.UsageUnit,a.ThesisNo,a.EngineNo,a.RegistrationNo*/
        /*Machine Damage History*/
        clsMachineDamage obMD = new clsMachineDamage();

        obMD.SiteMachineID = SiteMachineID;
        obMD.EntryDate1    = DateFrom;
        obMD.EntryDate2    = DateTo;
        obMD.Op            = 6;
        DataTable dtMD = obMD.MachineDamage(obMD).Tables[0];

        dt[1] = dtMD;
        /*ID, SiteID,Site,SiteMachineID,Machine,EntryDate,Remarks,IndentID,Indent*/
        /*Machine Progress History*/
        clsMachineryUsage obMU = new clsMachineryUsage();

        obMU.Op            = 8;
        obMU.SiteID        = SiteID;
        obMU.SiteMachineID = SiteMachineID;
        obMU.EntryDate1    = DateFrom;
        obMU.EntryDate2    = DateTo;

        DataTable dtMU = obMU.MachineryUsage(obMU).Tables[0];

        dt[2]   = dtMU;
        obMU.Op = 14;
        DataTable dtFuel = obMU.MachineryUsage(obMU).Tables[0];

        dt[3]   = dtFuel;
        obMU.Op = 13;
        DataTable dtBreakdown = obMU.MachineryUsage(obMU).Tables[0];

        dt[4] = dtBreakdown;

        /*ID,,EntryDate,Shift,ShiftText,SiteID,Site,SiteMachineID,Machine,OpenKMReading,CloseKMReading,TotalKMReading,OpenHRReading,CloseHRReading,TotalHRReading,OpenHSDReading,
         * CloseHSDReading,HSDIssue,TotalHSDReading,Breakdown,Idle,DriverName,Remarks,Status,EnteredBy*/
        /*Issue Slips*/
        clsSitePartIssue obSPI = new clsSitePartIssue();

        obSPI.Op         = 7;
        obSPI.EntryDate1 = DateFrom;
        obSPI.EntryDate2 = DateTo;

        obSPI.SiteMachineID = SiteMachineID;
        DataTable dtSPI = obSPI.SitePartIssue(obSPI).Tables[0];

        dt[5] = dtSPI;
        /*ID,SiteID,Site,SiteMachineID,Machine,IssueDate,IssueType,Issue,Detail,Quantity,Rate,Total,Remarks*/
        /*Machine Transfer*/
        clsMachineTransfer obMT = new clsMachineTransfer();

        obMT.Op            = 8;
        obMT.SiteMachineID = SiteMachineID;
        DataTable dtMT = obMT.MachineTransfer(obMT).Tables[0];

        dt[6] = dtMT;
        DataTable dtMTFinal = new DataTable();

        dtMTFinal.Columns.Add("Site");
        dtMTFinal.Columns.Add("FromDate");
        dtMTFinal.Columns.Add("ToDate");
        if (dtMT.Rows.Count > 0)
        {
            dtMTFinal.Rows.Add();
            dtMTFinal.Rows[0]["Site"]     = dtMT.Rows[0]["SourceSite"];
            dtMTFinal.Rows[0]["FromDate"] = Convert.ToDateTime(dtMT.Rows[0]["AddedOn"]).ToShortDateString();
            dtMTFinal.Rows[0]["ToDate"]   = Convert.ToDateTime(dtMT.Rows[0]["StartDate"]).ToShortDateString();
            for (int i = 1; i < dtMT.Rows.Count; i++)
            {
                dtMTFinal.Rows.Add();
                dtMTFinal.Rows[i]["Site"]     = dtMT.Rows[i]["SourceSite"];
                dtMTFinal.Rows[i]["FromDate"] = Convert.ToDateTime(dtMTFinal.Rows[i - 1]["UpdatedDate"]).ToShortDateString();
                dtMTFinal.Rows[i]["ToDate"]   = Convert.ToDateTime(dtMTFinal.Rows[i]["StartDate"]).ToShortDateString();
            }
        }
        dt[7] = dtMTFinal;
        Context.Response.Write(JsonConvert.SerializeObject(dt));
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        clsMachineryUsage obj = new clsMachineryUsage();

        obj.SiteID     = Convert.ToInt32(Request.Cookies["SiteID"].Value);
        obj.Shift      = Convert.ToInt32(ddlShift.SelectedValue);
        obj.EntryDate1 = Convert.ToDateTime(txtDate.Text).ToShortDateString();
        obj.Op         = 12;
        obj.MachineryUsage(obj);
        double TotalFuelUsed = 0;

        foreach (GridViewRow dr in grd.Rows)
        {
            Label       lblMachine         = dr.FindControl("lblMachine") as Label;
            HiddenField hdSiteMachineID    = dr.FindControl("hdSiteMachineID") as HiddenField;
            TextBox     txtOpenKMReading   = dr.FindControl("txtOpenKMReading") as TextBox;
            TextBox     txtCloseKMReading  = dr.FindControl("txtCloseKMReading") as TextBox;
            Label       lblTotalKMReading  = dr.FindControl("lblTotalKMReading") as Label;
            TextBox     txtOpenHReading    = dr.FindControl("txtOpenHReading") as TextBox;
            TextBox     txtOpenMReading    = dr.FindControl("txtOpenMReading") as TextBox;
            TextBox     txtCloseHReading   = dr.FindControl("txtCloseHReading") as TextBox;
            TextBox     txtCloseMReading   = dr.FindControl("txtCloseMReading") as TextBox;
            Label       lblTotalHRReading  = dr.FindControl("lblTotalHRReading") as Label;
            TextBox     txtOpenHSDReading  = dr.FindControl("txtOpenHSDReading") as TextBox;
            TextBox     txtHSDIssue        = dr.FindControl("txtHSDIssue") as TextBox;
            TextBox     txtCloseHSDReading = dr.FindControl("txtCloseHSDReading") as TextBox;
            Label       lblTotalHSDReading = dr.FindControl("lblTotalHSDReading") as Label;
            CheckBox    chkBreakdown       = dr.FindControl("chkBreakdown") as CheckBox;
            CheckBox    chkIdle            = dr.FindControl("chkIdle") as CheckBox;
            TextBox     txtDriver          = dr.FindControl("txtDriver") as TextBox;
            TextBox     txtRemarks         = dr.FindControl("txtRemarks") as TextBox;
            obj.SiteMachineID   = Convert.ToInt32(hdSiteMachineID.Value);
            obj.OpenKMReading   = Convert.ToDouble(txtOpenKMReading.Text);
            obj.CloseKMReading  = Convert.ToDouble(txtCloseKMReading.Text);
            obj.TotalKMReading  = Convert.ToDouble(lblTotalKMReading.Text);
            obj.OpenHRReading   = txtOpenHReading.Text + ":" + txtOpenMReading.Text;
            obj.CloseHRReading  = txtCloseHReading.Text + ":" + txtCloseMReading.Text;
            obj.TotalHRReading  = lblTotalHRReading.Text;
            obj.OpenHSDReading  = Convert.ToDouble(txtOpenHSDReading.Text);
            obj.CloseHSDReading = Convert.ToDouble(txtCloseHSDReading.Text);
            obj.HSDIssue        = Convert.ToDouble(txtHSDIssue.Text);
            TotalFuelUsed       = TotalFuelUsed + Convert.ToDouble(txtHSDIssue.Text);
            obj.TotalHSDReading = Convert.ToDouble(lblTotalHSDReading.Text);
            if (chkBreakdown.Checked == true)
            {
                obj.Breakdown = 1;
            }
            if (chkIdle.Checked == true)
            {
                obj.Idle = 1;
            }
            obj.DriverName = txtDriver.Text;
            obj.Remarks    = txtRemarks.Text;
            obj.Status     = 1;
            obj.EnteredBy  = Convert.ToInt32(Request.Cookies["User"].Value);
            obj.Op         = 1;
            obj.MachineryUsage(obj);
            if (chkBreakdown.Checked == true)
            {
                clsSiteMachines obSM = new clsSiteMachines();
                obSM.ID     = Convert.ToInt32(hdSiteMachineID.Value);
                obSM.Op     = 2;
                obSM.Status = 3;
                try { obSM.UpdateDate = txtDate.Text; }
                catch { }
                obSM.SiteMachines(obSM);
                clsMachineDamage obMD = new clsMachineDamage();
                obMD.SiteID        = Convert.ToInt32(Request.Cookies["SiteID"].Value);
                obMD.SiteMachineID = Convert.ToInt32(hdSiteMachineID.Value);
                obMD.EntryDate1    = Convert.ToDateTime(txtDate.Text).ToShortDateString();
                obMD.Remarks       = "Entry From Daily Progress Report";
                obMD.Op            = 1;
                obMD.MachineDamage(obMD);
            }
            else
            {
                if (chkIdle.Checked == true)
                {
                    clsSiteMachines obSM = new clsSiteMachines();
                    obSM.ID     = Convert.ToInt32(hdSiteMachineID.Value);
                    obSM.Op     = 2;
                    obSM.Status = 2;
                    try { obSM.UpdateDate = txtDate.Text; }
                    catch { }
                    obSM.SiteMachines(obSM);
                }
                else
                {
                    clsSiteMachines obSM = new clsSiteMachines();
                    obSM.ID     = Convert.ToInt32(hdSiteMachineID.Value);
                    obSM.Op     = 2;
                    obSM.Status = 1;
                    try { obSM.UpdateDate = txtDate.Text; }
                    catch { }
                    obSM.SiteMachines(obSM);
                }
            }
        }
        clsSiteFuelIssue obSFI = new clsSiteFuelIssue();

        obSFI.SiteID = Convert.ToInt32(Request.Cookies["SiteID"].Value);
        try { obSFI.IssueDate1 = Convert.ToDateTime(txtDate.Text).ToShortDateString(); }
        catch { }
        obSFI.InAmount  = Convert.ToDouble(txtFuelIssued.Text);
        obSFI.OutAmount = TotalFuelUsed;
        obSFI.Balance   = Convert.ToDouble(txtFuelBalance.Text);
        obSFI.Rate      = 0;
        obSFI.Total     = 0;
        obSFI.Remarks   = "Entry from Daily Progress Report";
        obSFI.Op        = 1;
        obSFI.SiteFuelIssue(obSFI);
        LoadMachines();
        LoadFuel();
    }