Пример #1
0
    public static void Filial_Update(Filial filial)
    {
        int?filialAddressId;

        if (filial.FilialAddress.Id <= 0)
        {
            filialAddressId = filial.FilialAddress.Set();
        }
        else
        {
            if (filial.FilialAddress.IsEmpty())             //Luego del uptade de Filial se borra el registro
            {
                filialAddressId = null;
            }
            else
            {
                filialAddressId = filial.FilialAddress.Id;
            }
        }

        db.ExecuteScalar("spFilialUpdate", filial.Id, filial.TaxpayerId,
                         filial.Birthdate, filial.Birthplace, filial.DocumentType1.Id, filial.DocumentNumber1,
                         filial.DocumentType2.Id, filial.DocumentNumber2, filial.DocumentType3.Id, filial.DocumentNumber3,
                         filialAddressId, filial.Sex.Id, filial.MartialStatus.Id, filial.PdfFile,
                         HttpContext.Current.Session["UserId"]);
        filial.CopyValuesToOrigValues();

        if (filial.FilialAddress.Id > 0)
        {
            filialAddressId = filial.FilialAddress.Set();
        }
    }
Пример #2
0
    public static Filial Filial_GetByTaxpayerId(int id)
    {
        Filial  filial = null;
        DataSet ds     = db.ExecuteDataSet("spFilialGetByTaxpayerId", id);

        if (ds.Tables[0].Rows.Count > 0)
        {
            DataRow dr = ds.Tables[0].Rows[0];
            filial            = new Filial();
            filial.Id         = Convert.ToInt32(dr["Id"]);
            filial.TaxpayerId = Convert.ToInt32(dr["TaxpayerId"]);
            if ((dr["Birthdate"] != DBNull.Value))
            {
                filial.Birthdate = (DateTime?)(dr["Birthdate"]);
            }
            filial.Birthplace      = dr["Birthplace"].ToString();
            filial.DocumentType1   = new Code(Convert.ToInt32(dr["DocumentTypeId1"]));
            filial.DocumentNumber1 = dr["DocumentNumber1"].ToString();
            filial.DocumentType2   = new Code(Convert.ToInt32(dr["DocumentTypeId2"]));
            filial.DocumentNumber2 = dr["DocumentNumber2"].ToString();
            filial.DocumentType3   = new Code(Convert.ToInt32(dr["DocumentTypeId3"]));
            filial.DocumentNumber3 = dr["DocumentNumber3"].ToString();
            if (dr["AddressId"] != DBNull.Value)
            {
                filial.FilialAddress = Address_GetById(Convert.ToInt32(dr["AddressId"]));
            }

            filial.Sex           = new Code(Convert.ToInt32(dr["SexId"]));
            filial.MartialStatus = new Code(Convert.ToInt32(dr["MartialStatusId"]));
            filial.PdfFile       = dr["PdfFile"].ToString();

            filial.CopyValuesToOrigValues();
        }
        return(filial);
    }
Пример #3
0
    public static int?Filial_Insert(Filial filial)
    {
        int?filialAddressId = filial.FilialAddress.Set();

        return(Convert.ToInt32(db.ExecuteScalar("spFilialInsert", filial.TaxpayerId,
                                                filial.Birthdate, filial.Birthplace, filial.DocumentType1.Id, filial.DocumentNumber1,
                                                filial.DocumentType2.Id, filial.DocumentNumber2, filial.DocumentType3.Id, filial.DocumentNumber3,
                                                filialAddressId, filial.Sex.Id, filial.MartialStatus.Id, filial.PdfFile,
                                                HttpContext.Current.Session["UserId"])));

        filial.CopyValuesToOrigValues();
    }