示例#1
0
        public bool Save <T>(T item) where T : IContract
        {
            var result = 0;
            var driver = (Driver)(object)item;

            if (currentTransaction == null)
            {
                connection = db.CreateConnection();
                connection.Open();
            }

            var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction);

            try
            {
                var savecommand = db.GetStoredProcCommand(DBRoutine.SAVEDRIVER);
                db.AddInParameter(savecommand, "DriverID", System.Data.DbType.String, driver.DriverID);
                db.AddInParameter(savecommand, "DriverName", System.Data.DbType.String, driver.DriverName);
                db.AddInParameter(savecommand, "Password", System.Data.DbType.String, driver.Password);
                db.AddInParameter(savecommand, "VehicleNo", System.Data.DbType.String, "");
                db.AddInParameter(savecommand, "FatherName", System.Data.DbType.String, driver.FatherName);
                db.AddInParameter(savecommand, "DateOfBirth", System.Data.DbType.DateTime, driver.DateOfBirth);
                db.AddInParameter(savecommand, "PlaceOfBirth", System.Data.DbType.String, driver.PlaceOfBirth);
                db.AddInParameter(savecommand, "Gender", System.Data.DbType.Int16, driver.Gender);
                db.AddInParameter(savecommand, "MaritialStatus", System.Data.DbType.Int16, driver.MaritialStatus);
                db.AddInParameter(savecommand, "MobileNo", System.Data.DbType.String, driver.MobileNo);
                db.AddInParameter(savecommand, "PhoneNo", System.Data.DbType.String, driver.PhoneNo);
                db.AddInParameter(savecommand, "PANNo", System.Data.DbType.String, driver.PANNo);
                db.AddInParameter(savecommand, "AadharCardNo", System.Data.DbType.String, driver.AadharCardNo);
                db.AddInParameter(savecommand, "LicenseNo", System.Data.DbType.String, driver.LicenseNo);
                //db.AddInParameter(savecommand, "Status", System.Data.DbType.Boolean, driver.Status);
                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, driver.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, driver.ModifiedBy);
                db.AddInParameter(savecommand, "Nationality", System.Data.DbType.String, driver.Nationality ?? "Indian");
                //db.AddInParameter(savecommand, "DeviceID", System.Data.DbType.String, driver.DeviceID);
                db.AddOutParameter(savecommand, "NewDocumentNo", System.Data.DbType.String, 50);
                db.AddInParameter(savecommand, "OperatorID", System.Data.DbType.String, driver.OperatorID);

                result = db.ExecuteNonQuery(savecommand, transaction);

                if (result > 0)
                {
                    var newDocumentNo = savecommand.Parameters["@NewDocumentNo"].Value.ToString();
                    // var newDocumentNo = db.GetParameterValue(savecommand, "NewDocumentNo").ToString();
                    if (driver.AddressList != null && driver.AddressList.Count > 0)
                    {
                        foreach (var addressItem in driver.AddressList)
                        {
                            addressItem.AddressLinkID = newDocumentNo;
                        }


                        driver.AddressList.ForEach(x =>
                        {
                            result = new AddressDAL().Save(x, transaction) == true ? 1 : 0;
                        });
                    }
                    if (currentTransaction == null)
                    {
                        transaction.Commit();
                    }
                }
            }
            catch (Exception ex)
            {
                if (currentTransaction == null)
                {
                    transaction.Rollback();
                }

                throw ex;
            }
            finally
            {
                transaction.Dispose();
                connection.Close();
            }

            return(result > 0 ? true : false);
        }
示例#2
0
        public bool Save <T>(T item) where T : IContract
        {
            var result = 0;
            var driver = (Driver)(object)item;

            if (currentTransaction == null)
            {
                connection = db.CreateConnection();
                connection.Open();
            }

            var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction);

            try
            {
                var savecommand = db.GetStoredProcCommand(DBRoutine.SAVEDRIVER);
                db.AddInParameter(savecommand, "DriverID", System.Data.DbType.String, driver.DriverId);
                db.AddInParameter(savecommand, "DriverName", System.Data.DbType.String, driver.DriverName);
                db.AddInParameter(savecommand, "Password", System.Data.DbType.String, driver.MobileNo);
                db.AddInParameter(savecommand, "VehicleNo", System.Data.DbType.String, "");
                db.AddInParameter(savecommand, "FatherName", System.Data.DbType.String, driver.FatherName);
                db.AddInParameter(savecommand, "DateOfBirth", System.Data.DbType.DateTime, driver.DateOfBirth);
                db.AddInParameter(savecommand, "PlaceOfBirth", System.Data.DbType.String, driver.PlaceOfBirth);
                db.AddInParameter(savecommand, "Gender", System.Data.DbType.Int16, driver.Gender);
                db.AddInParameter(savecommand, "MaritialStatus", System.Data.DbType.Int16, driver.MaritialStatus);
                db.AddInParameter(savecommand, "MobileNo", System.Data.DbType.String, driver.MobileNo);
                db.AddInParameter(savecommand, "PhoneNo", System.Data.DbType.String, driver.PhoneNo);
                db.AddInParameter(savecommand, "PANNo", System.Data.DbType.String, driver.PANNo);
                db.AddInParameter(savecommand, "AadharCardNo", System.Data.DbType.String, driver.AadharCardNo);
                db.AddInParameter(savecommand, "LicenseNo", System.Data.DbType.String, driver.LicenseNo);
                //db.AddInParameter(savecommand, "Status", System.Data.DbType.Boolean, driver.Status);
                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, driver.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, driver.ModifiedBy);
                db.AddInParameter(savecommand, "Nationality", System.Data.DbType.String, driver.Nationality ?? "Indian");
                db.AddInParameter(savecommand, "OperatorID", System.Data.DbType.String, driver.OperatorId);
                //db.AddInParameter(savecommand, "DeviceID", System.Data.DbType.String, driver.DeviceID);

                db.AddInParameter(savecommand, "MobileMake", System.Data.DbType.String, driver.MobileMake);
                db.AddInParameter(savecommand, "ModelNo", System.Data.DbType.String, driver.ModelNo);
                db.AddInParameter(savecommand, "DateofIssue", System.Data.DbType.DateTime, driver.DateofIssue);
                db.AddInParameter(savecommand, "DateofReturn", System.Data.DbType.DateTime, driver.DateofReturn);
                db.AddOutParameter(savecommand, "NewDocumentNo", System.Data.DbType.String, 50);


                result = db.ExecuteNonQuery(savecommand, transaction);

                if (result > 0)
                {
                    var newDocumentNo = savecommand.Parameters["@NewDocumentNo"].Value.ToString();
                    // var newDocumentNo = db.GetParameterValue(savecommand, "NewDocumentNo").ToString();
                    if (driver.driverAttachment != null && driver.driverAttachment.Count > 0)
                    {
                        foreach (var driverAttachment in driver.driverAttachment)
                        {
                            driverAttachment.DriverId     = newDocumentNo;
                            driverAttachment.AttachmentId = newDocumentNo + driverAttachment.LookupCode;

                            //postedFile.SaveAs(filePath);
                        }
                        result = new DriverAttachementDAL().SaveList(driver.driverAttachment, transaction) == true ? 1 : 0;
                    }
                    //if (driver.operatorDriverList != null&& driver.operatorDriverList.Count > 0)
                    //{
                    //    result = new DriverAttachementDAL().SaveList(driver.driverAttachment, transaction) == true ? 1 : 0;
                    //}
                    if (driver.AddressList != null && driver.AddressList.Count > 0)
                    {
                        foreach (var addressItem in driver.AddressList)
                        {
                            addressItem.AddressLinkId = newDocumentNo;
                        }


                        driver.AddressList.ForEach(x =>
                        {
                            result = new AddressDAL().Save(x, transaction) == true ? 1 : 0;
                        });
                    }

                    if (driver.BankDetails != null && driver.BankDetails.Count > 0)
                    {
                        foreach (var bankItem in driver.BankDetails)
                        {
                            bankItem.OperatorBankID = driver.DriverId;
                        }

                        driver.BankDetails.ForEach(x => {
                            new BankDetailsDAL().Save(x);
                        });
                    }

                    //string path = Server.MapPath("~/PickCApi/DriverImages");

                    //if (!Directory.Exists(path))
                    //{
                    //    Directory.CreateDirectory(path);
                    //}
                    //fileContent.SaveAs(path + fileContent.FileName);


                    //for (int i = 0; i < request.Files.Count; i++)
                    //{
                    //    var file = request.Files[i];

                    //    var ext = new FileInfo(file.FileName).Extension;
                    //    var fullPath = Path.Combine(StorageRoot, Path.GetFileName(Guid.NewGuid() + ext));

                    //    file.SaveAs(fullPath);
                    //}



                    if (currentTransaction == null)
                    {
                        transaction.Commit();
                    }
                }
            }
            catch (Exception ex)
            {
                if (currentTransaction == null)
                {
                    transaction.Rollback();
                }

                throw ex;
            }
            finally
            {
                transaction.Dispose();
                connection.Close();
            }

            return(result > 0 ? true : false);
        }
示例#3
0
        public bool Save <T>(T item) where T : IContract
        {
            var result       = 0;
            var operatorItem = (Operator)(object)item;

            if (currentTransaction == null)
            {
                connection = db.CreateConnection();
                connection.Open();
            }

            var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction);

            try
            {
                var savecommand = db.GetStoredProcCommand(DBRoutine.SAVEOPERATOR);
                db.AddInParameter(savecommand, "OperatorID", System.Data.DbType.String, operatorItem.OperatorID ?? "");
                db.AddInParameter(savecommand, "OperatorName", System.Data.DbType.String, operatorItem.OperatorName);
                db.AddInParameter(savecommand, "Password", System.Data.DbType.String, operatorItem.Password);
                db.AddInParameter(savecommand, "FatherName", System.Data.DbType.String, operatorItem.FatherName);
                db.AddInParameter(savecommand, "DateOfBirth", System.Data.DbType.DateTime, operatorItem.DateOfBirth);
                db.AddInParameter(savecommand, "PlaceOfBirth", System.Data.DbType.String, operatorItem.PlaceOfBirth);
                db.AddInParameter(savecommand, "Gender", System.Data.DbType.Int16, operatorItem.Gender);
                db.AddInParameter(savecommand, "MaritialStatus", System.Data.DbType.Int16, operatorItem.MaritialStatus);
                db.AddInParameter(savecommand, "MobileNo", System.Data.DbType.String, operatorItem.MobileNo);
                db.AddInParameter(savecommand, "PhoneNo", System.Data.DbType.String, operatorItem.PhoneNo);
                db.AddInParameter(savecommand, "PANNo", System.Data.DbType.String, operatorItem.PANNo);
                db.AddInParameter(savecommand, "AadharCardNo", System.Data.DbType.String, operatorItem.AadharCardNo);
                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, operatorItem.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, operatorItem.ModifiedBy);
                db.AddInParameter(savecommand, "Nationality", System.Data.DbType.String, operatorItem.Nationality ?? "Indian");
                db.AddOutParameter(savecommand, "NewDocumentNo", System.Data.DbType.String, 50);
                result = db.ExecuteNonQuery(savecommand, transaction);
                if (result > 0)
                {
                    operatorItem.OperatorID = savecommand.Parameters["@NewDocumentNo"].Value.ToString();

                    if (operatorItem.operatorAttachment != null && operatorItem.operatorAttachment.Count > 0)
                    {
                        foreach (var operatorAttachment in operatorItem.operatorAttachment)
                        {
                            operatorAttachment.operatorId   = operatorItem.OperatorID;
                            operatorAttachment.attachmentId = operatorItem.OperatorID + operatorAttachment.lookupCode;
                        }
                        result = new OperatorAttachementDAL().SaveList(operatorItem.operatorAttachment, transaction) == true ? 1 : 0;
                    }
                    if (operatorItem.BankDetails != null && operatorItem.BankDetails.Count > 0)
                    {
                        operatorItem.BankDetails.ForEach(x =>
                                                         { x.OperatorBankID = operatorItem.OperatorID;
                                                           result = new BankDetailsDAL().Save(x, transaction) == true ? 1 : 0; });
                    }

                    if (operatorItem.OperatorDriverList != null && operatorItem.OperatorDriverList.Count > 0)
                    {
                        operatorItem.OperatorDriverList.ForEach(x =>
                        {
                            x.OperatorDriverId = operatorItem.OperatorID;
                            result             = new OperatorDriverDAL().Save(x, transaction) == true ? 1 : 0;
                        });
                    }

                    if (operatorItem.OperatorVehicle != null && operatorItem.OperatorVehicle.Count > 0)
                    {
                        operatorItem.OperatorVehicle.ForEach(x =>
                        {
                            x.OperatorVehicleID = operatorItem.OperatorID;
                            result = new OperatorVehicleDAL().Save(x, transaction) == true ? 1 : 0;
                        });
                    }
                    if (operatorItem.AddressList != null && operatorItem.AddressList.Count > 0)
                    {
                        //foreach (var addressItem in operatorItem.AddressList)
                        //{
                        //    addressItem.AddressLinkID = operatorItem.OperatorID;
                        //}
                        operatorItem.AddressList.ForEach(x =>
                                                         { x.AddressLinkId = operatorItem.OperatorID;
                                                           result = new AddressDAL().Save(x, transaction) == true ? 1 : 0; });
                    }
                    if (currentTransaction == null)
                    {
                        transaction.Commit();
                    }
                }
            }
            catch (Exception ex)
            {
                if (currentTransaction == null)
                {
                    transaction.Rollback();
                }

                throw ex;
            }
            finally
            {
                transaction.Dispose();
                connection.Close();
            }

            return(result > 0 ? true : false);
        }
示例#4
0
        //// added by Kiran////
        public bool SaveDriverDetails <T>(T item) where T : IContract
        {
            var result = 0;
            var driver = (DriverMdl)(object)item;

            if (currentTransaction == null)
            {
                connection = db.CreateConnection();
                connection.Open();
            }

            var transaction = (currentTransaction == null ? connection.BeginTransaction() : currentTransaction);

            try
            {
                var savecommand = db.GetStoredProcCommand(DBRoutine.SAVEDRIVERDETAILS);
                db.AddInParameter(savecommand, "DriverID", System.Data.DbType.String, driver.DriverId);
                db.AddInParameter(savecommand, "DriverName", System.Data.DbType.String, driver.DriverName);
                db.AddInParameter(savecommand, "Password", System.Data.DbType.String, driver.Password);
                db.AddInParameter(savecommand, "VehicleNo", System.Data.DbType.String, "");
                db.AddInParameter(savecommand, "FatherName", System.Data.DbType.String, driver.FatherName);
                db.AddInParameter(savecommand, "DateOfBirth", System.Data.DbType.DateTime, driver.DateOfBirth);
                db.AddInParameter(savecommand, "PlaceOfBirth", System.Data.DbType.String, driver.PlaceOfBirth);
                db.AddInParameter(savecommand, "Gender", System.Data.DbType.Int16, driver.Gender);
                db.AddInParameter(savecommand, "MaritialStatus", System.Data.DbType.Int16, driver.MaritialStatus);
                db.AddInParameter(savecommand, "MobileNo", System.Data.DbType.String, driver.MobileNo);
                db.AddInParameter(savecommand, "PhoneNo", System.Data.DbType.String, driver.PhoneNo);
                db.AddInParameter(savecommand, "PANNo", System.Data.DbType.String, driver.PANNo);
                db.AddInParameter(savecommand, "AadharCardNo", System.Data.DbType.String, driver.AadharCardNo);
                db.AddInParameter(savecommand, "LicenseNo", System.Data.DbType.String, driver.LicenseNo);
                //db.AddInParameter(savecommand, "Status", System.Data.DbType.Boolean, driver.Status);
                db.AddInParameter(savecommand, "CreatedBy", System.Data.DbType.String, driver.CreatedBy);
                db.AddInParameter(savecommand, "ModifiedBy", System.Data.DbType.String, driver.ModifiedBy);
                db.AddInParameter(savecommand, "Nationality", System.Data.DbType.String, driver.Nationality ?? "Indian");
                db.AddInParameter(savecommand, "OperatorID", System.Data.DbType.String, driver.OperatorId);
                //db.AddInParameter(savecommand, "DeviceID", System.Data.DbType.String, driver.DeviceID);

                db.AddInParameter(savecommand, "MobileMake", System.Data.DbType.String, driver.MobileMake);
                db.AddInParameter(savecommand, "ModelNo", System.Data.DbType.String, driver.ModelNo);
                db.AddInParameter(savecommand, "DateofIssue", System.Data.DbType.DateTime, driver.DateofIssue.ToLocalTime());
                db.AddInParameter(savecommand, "DateofReturn", System.Data.DbType.DateTime, driver.DateofReturn.ToLocalTime());
                db.AddOutParameter(savecommand, "NewDocumentNo", System.Data.DbType.String, 50);
                db.AddInParameter(savecommand, "DeviceRemarks", System.Data.DbType.String, driver.DeviceRemarks);

                result = db.ExecuteNonQuery(savecommand, transaction);

                if (result > 0)
                {
                    var newDocumentNo = savecommand.Parameters["@NewDocumentNo"].Value.ToString();
                    driver.DriverId = newDocumentNo;
                    // var newDocumentNo = db.GetParameterValue(savecommand, "NewDocumentNo").ToString();
                    if (driver.driverAttachment != null && driver.driverAttachment.Count > 0)
                    {
                        foreach (var driverAttachment in driver.driverAttachment)
                        {
                            driverAttachment.DriverId     = newDocumentNo;
                            driverAttachment.AttachmentId = newDocumentNo + driverAttachment.LookupCode;
                        }
                        result = new DriverAttachementDAL().SaveList(driver.driverAttachment, transaction) == true ? 1 : 0;
                    }
                    if (driver.AddressList != null && driver.AddressList.Count > 0)
                    {
                        //foreach (var addressItem in driver.AddressList)
                        //{
                        //	addressItem.AddressLinkId = newDocumentNo;
                        //}
                        //driver.AddressList.ForEach(y =>
                        //  {
                        //      y.AddressLinkId = newDocumentNo;
                        //  });

                        driver.AddressList.ForEach(y => {
                            y.AddressLinkId = newDocumentNo;
                            new AddressDAL().DeleteAll(y);
                        });
                        driver.AddressList.ForEach(x =>
                        {
                            x.AddressLinkId = newDocumentNo;
                            result          = new AddressDAL().Save(x, transaction) == true ? 1 : 0;
                        });
                    }


                    if (driver.BankDetails != null && driver.BankDetails.Count > 0)
                    {
                        foreach (var bankItem in driver.BankDetails)
                        {
                            bankItem.OperatorBankID = driver.DriverId;
                        }

                        driver.BankDetails.ForEach(x => {
                            new BankDetailsDAL().Save(x);
                        });
                    }
                    if (currentTransaction == null)
                    {
                        transaction.Commit();
                    }
                }
            }
            catch (Exception ex)
            {
                if (currentTransaction == null)
                {
                    transaction.Rollback();
                }

                throw ex;
            }
            finally
            {
                transaction.Dispose();
                connection.Close();
            }

            return(result > 0 ? true : false);
        }