예제 #1
0
        private void Csr_Save(string docketNo)
        {
            Business.Service.ServiceBook objServiceBook = new Business.Service.ServiceBook();
            DataSet ds = objServiceBook.Service_CSR_GetByDocketNo(docketNo);

            Entity.Service.CsrJson csrJson = new Entity.Service.CsrJson();
            Entity.Service.Csr     csr     = new Entity.Service.Csr();

            if (ds != null)
            {
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    csrJson.ProductName     = ds.Tables[0].Rows[0]["ProductName"].ToString();
                    csrJson.MachineId       = ds.Tables[0].Rows[0]["MachineId"].ToString();
                    csrJson.DocketNo        = ds.Tables[0].Rows[0]["DocketNo"].ToString();
                    csrJson.CustomerCode    = ds.Tables[0].Rows[0]["CustomerCode"].ToString();
                    csrJson.CustomerName    = ds.Tables[0].Rows[0]["CustomerName"].ToString();
                    csrJson.CustomerAddress = ds.Tables[0].Rows[0]["Address"].ToString();
                    csrJson.ProductSerialNo = ds.Tables[0].Rows[0]["ProductSerialNo"].ToString();
                    csrJson.DocketDate      = ds.Tables[0].Rows[0]["DocketDate"].ToString();
                    csrJson.DocketTime      = ds.Tables[0].Rows[0]["DocketTime"].ToString();
                    csrJson.DocketType      = ds.Tables[0].Rows[0]["DocketType"].ToString();
                    csrJson.Problem         = ds.Tables[0].Rows[0]["Problem"].ToString();
                    csrJson.ActionTaken     = ds.Tables[0].Rows[0]["ActionTaken"].ToString();
                    csrJson.Diagnosis       = ds.Tables[0].Rows[0]["Diagonosis"].ToString();
                    csrJson.Signature       = ds.Tables[0].Rows[0]["Signature"].ToString();
                    csrJson.Stamp           = ds.Tables[0].Rows[0]["Stamp"].ToString();
                    /* Checking whether machine is in contract or not*/
                    Business.Service.Contract objContract = new Business.Service.Contract();
                    if (objContract.Service_MachineIsInContractCheck(Convert.ToInt32(ds.Tables[0].Rows[0]["CustomerPurchaseId"].ToString())))
                    {
                        csrJson.IsInContract = true;
                    }
                    else
                    {
                        csrJson.IsInContract = false;
                    }
                }
                if (ds.Tables[3] != null && ds.Tables[3].Rows.Count > 0)
                {
                    csrJson.A3BWMeterReading = ds.Tables[3].Rows[0]["A3BWMeterReading"].ToString();
                    csrJson.A3CLMeterReading = ds.Tables[3].Rows[0]["A3CLMeterReading"].ToString();
                    csrJson.A4BWMeterReading = ds.Tables[3].Rows[0]["A4BWMeterReading"].ToString();
                    csrJson.A4CLMeterReading = ds.Tables[3].Rows[0]["A4CLMeterReading"].ToString();
                }
                if (ds.Tables[1] != null && ds.Tables[1].Rows.Count > 0)
                {
                    List <Entity.Service.CallAttendance> callAttendances = new List <Entity.Service.CallAttendance>();

                    foreach (DataRow dataRow in ds.Tables[1].Rows)
                    {
                        callAttendances.Add(new Entity.Service.CallAttendance()
                        {
                            EmployeeName  = dataRow["EmployeeName"].ToString(),
                            InDate        = dataRow["InDate"].ToString(),
                            InTime        = dataRow["InTime"].ToString(),
                            OutDate       = dataRow["OutDate"].ToString(),
                            OutTime       = dataRow["OutTime"].ToString(),
                            ProblemStatus = dataRow["ProblemStatus"].ToString()
                        });
                    }
                    csrJson.callAttendances = new List <Entity.Service.CallAttendance>();
                    csrJson.callAttendances = callAttendances;
                }
                if (ds.Tables[2] != null && ds.Tables[2].Rows.Count > 0)
                {
                    List <Entity.Service.SpareUsed> sparesUsed = new List <Entity.Service.SpareUsed>();

                    foreach (DataRow dataRow in ds.Tables[2].Rows)
                    {
                        sparesUsed.Add(new Entity.Service.SpareUsed()
                        {
                            SpareName = dataRow["SpareName"].ToString()
                        });
                    }
                    csrJson.sparesUsed = new List <Entity.Service.SpareUsed>();
                    csrJson.sparesUsed = sparesUsed;
                }
                csr.CsrContent    = JsonConvert.SerializeObject(csrJson);
                csr.ServiceBookId = Convert.ToInt64(ds.Tables[0].Rows[0]["ServiceBookId"].ToString());
                csr.CreatedBy     = Convert.ToInt32(HttpContext.Current.User.Identity.Name);
            }
            objServiceBook.Service_CsrSave(csr);
        }