protected override void Recuperar_Registro() { CCompanyFactory faCompany = new CCompanyFactory(); CCompany oCompany = faCompany.GetByPrimaryKey(new CCompanyKeys(IDCompany)); if (oCompany != null) { tbBusinessName.Text = oCompany.Business_name; tbClientRuc.Text = oCompany.Ruc; tbClientDomicile.Text = oCompany.Domicile; tbClientEmail.Text = oCompany.Mail; tbClientPhone.Text = oCompany.Phone_client; cbTypeCompany.EditValue = Convert.ToChar(oCompany.Type_company); } }
protected override bool Grabar_Registro() { CCompanyFactory faCompany = new CCompanyFactory(); CCompany oCompany; if ((oCompany = faCompany.GetByPrimaryKey(new CCompanyKeys(IDCompany))) == null) { oCompany = new CCompany(); } oCompany.Idcompany = IDCompany; oCompany.Business_name = tbBusinessName.Text; oCompany.Domicile = tbClientDomicile.Text; oCompany.Mail = tbClientEmail.Text; oCompany.Phone_client = tbClientPhone.Text; oCompany.Ruc = tbClientRuc.Text; oCompany.Type_company = Convert.ToChar(cbTypeCompany.EditValue); if (IDCompany == 0) { oCompany.Usernew = Comun.GetUser(); oCompany.Useredit = Comun.GetUser(); oCompany.Datenew = Comun.GetDate(); oCompany.Dateedit = Comun.GetDate(); } else { oCompany.Useredit = Comun.GetUser(); oCompany.Dateedit = Comun.GetDate(); } bool result = false; if (!(result = faCompany.Update(oCompany))) { if (!result) { result = faCompany.Insert(oCompany); } } if (result) { LoadDataMasterSearh(new CCompanyFactory().GetAllDataTable()); } return(result); }
protected override bool Grabar_Registro() { CCompanyFactory faCompany = new CCompanyFactory(); CCompany oCompany; if ((oCompany = faCompany.GetByPrimaryKey(new CCompanyKeys(IDCompany))) == null) oCompany = new CCompany(); oCompany.Idcompany = IDCompany; oCompany.Business_name = tbBusinessName.Text; oCompany.Domicile = tbClientDomicile.Text; oCompany.Mail = tbClientEmail.Text; oCompany.Phone_client = tbClientPhone.Text; oCompany.Ruc = tbClientRuc.Text; oCompany.Type_company = Convert.ToChar(cbTypeCompany.EditValue); if (IDCompany == 0) { oCompany.Usernew = Comun.GetUser(); oCompany.Useredit = Comun.GetUser(); oCompany.Datenew = Comun.GetDate(); oCompany.Dateedit = Comun.GetDate(); } else { oCompany.Useredit = Comun.GetUser(); oCompany.Dateedit = Comun.GetDate(); } bool result = false; if (!(result = faCompany.Update(oCompany))) { if (!result) { result = faCompany.Insert(oCompany); } } if (result) LoadDataMasterSearh(new CCompanyFactory().GetAllDataTable()); return result; }
void RetrieveDataCompany() { // --- recuperate the clients if (cbCompany.EditValue != null) { if (cbCompany.EditValue.ToString().Trim() != "" && cbCompany.EditValue.ToString().Trim() != "0") { CCompany oCompany = new CCompany(); CCompanyFactory faCompany = new CCompanyFactory(); oCompany = faCompany.GetByPrimaryKey(new CCompanyKeys(Convert.ToInt16(cbCompany.EditValue))); tbClientDomicile.Text = oCompany.Domicile; tbClientPhone.Text = oCompany.Phone_client; tbClientRuc.Text = oCompany.Ruc; // --- get/show contacts Reception oReception = new BusinessLayer.Modules.Reception(); ModPrice oModPrice = new ModPrice(); gcContact.DataSource = new BindingList <CContact_price>(oModPrice.GetLstContactsByCompany(oCompany.Idcompany)); } } }
private void FormMaterialReference_Load(object sender, EventArgs e) { // --- Initialize material of reference CMrFactory faMr = new CMrFactory(); cbCodMR.Properties.DataSource = faMr.GetAll(); cbCodMR.Properties.ValueMember = "Idmr"; cbCodMR.Properties.DisplayMember = "Cod_mr"; // --- Initialize description sample cbDescription.Properties.DataSource = Comun.ListTypeMaterial; cbDescription.Properties.ValueMember = "IdTypeMaterial"; cbDescription.Properties.DisplayMember = "Description"; // --- Initialize type of analysis CDigestion_methodFactory faDigestion_method = new CDigestion_methodFactory(); repTypeDigestion.DataSource = faDigestion_method.GetAll(); repTypeDigestion.ValueMember = "Cod_digestion_method"; repTypeDigestion.DisplayMember = "Name_digestion_method"; // --- Initialize the type of material reference cbTypeMr.Properties.DataSource = Comun.ListMr; cbTypeMr.Properties.DisplayMember = "Den_TypeMr"; cbTypeMr.Properties.ValueMember = "IdTypeMr"; // --- Initialize in container grid element CElementFactory faElement = new CElementFactory(); repElement.DataSource = faElement.GetAll(); repElement.DisplayMember = "Cod_element"; repElement.ValueMember = "Idelement"; // --- Initialize in container grid unit measurement CMeasurement_unitFactory faMeasurement_unit = new CMeasurement_unitFactory(); repTypeUnit.DataSource = faMeasurement_unit.GetAll(); repTypeUnit.DisplayMember = "Name_unit"; repTypeUnit.ValueMember = "Idunit"; // --- Inititalize list statusMr lstStatusMr = new BindingList<CStatusMr>(); lstStatusMr.Add(new CStatusMr { IDStatusMr = true, Description = "Vigente" }); lstStatusMr.Add(new CStatusMr { IDStatusMr = false, Description = "No vigente" }); cbStatus.Properties.DataSource = lstStatusMr; cbStatus.Properties.DisplayMember = "Description"; cbStatus.Properties.ValueMember = "IDStatusMr"; // --- Initialize in container grid company CCompanyFactory faCompany = new CCompanyFactory(); List<CCompany> lstCompany = faCompany.GetAll().Where(c=> c.Type_company == 'P').ToList(); cbManufacturer.Properties.DataSource = lstCompany; cbManufacturer.Properties.DisplayMember = "Business_name"; cbManufacturer.Properties.ValueMember = "Idcompany"; cbCertifier.Properties.DataSource = lstCompany; cbCertifier.Properties.DisplayMember = "Business_name"; cbCertifier.Properties.ValueMember = "Idcompany"; // --- Initialize the grid GetDetailMaterialReference(); }
void InitCombos() { repRepetition.DataSource = Comun.ListTypeRepetition; repRepetition.ValueMember = "Cod_repetition"; repRepetition.DisplayMember = "Name_repetition"; List<CType_sample> lstType_sample = new CType_sampleFactory().GetAll(); cbTypeSample.Properties.DataSource = lstType_sample; cbTypeSample.Properties.DisplayMember = "Cod_type_sample"; cbTypeSample.Properties.ValueMember = "Cod_type_sample"; cbTypeSample.EditValue = lstType_sample[0].Cod_type_sample; InitComboFilterAthorization(); List<CCompany> lstCompany = new CCompanyFactory().GetAll(); cbCompany.Properties.DataSource = lstCompany; cbCompany.Properties.DisplayMember = "Business_name"; cbCompany.Properties.ValueMember = "Idcompany"; cbCompany.EditValue = lstCompany[0].Cod_company; List<CDescription_sample> lstDescription = new CDescription_sampleFactory().GetAll(); repDes_Sample.DataSource = lstDescription; repDes_Sample.DisplayMember = "Description"; repDes_Sample.ValueMember = "Cod_des_sample"; }
protected override bool Grabar_Registro() { // --- save company bool result_company = false; CCompany oCompany = new CCompany(); if (cbCompany.EditValue != null) { CCorr_modulesFactory faCorr_modules = new CCorr_modulesFactory(); CCompanyFactory faCompany = new CCompanyFactory(); oCompany.Idcompany = Convert.ToInt16(cbCompany.EditValue); //oCompany.Cod_company = faCorr_modules.GetCorrModule(Comun.Formulario.fmEmpresa.ToString()); oCompany.Ruc = tbClientRuc.Text; oCompany.Business_name = cbCompany.Text; oCompany.Domicile = tbClientDomicile.Text; oCompany.Type_company = 'C'; // --- client oCompany.Phone_client = tbClientPhone.Text; if (!(result_company = faCompany.Update(oCompany))) { result_company = faCompany.Insert(oCompany); } } bool result_price = false; if (oPrice == null) { oPrice = new CPrice(); } CPriceFactory faPrice = new CPriceFactory(); if (!(loadData == LoadData.FromPrice_ToNewVersion)) { oPrice.Cod_price = new ModCorrelatives().GetCorrelative(Comun.Correlative.Price); } // --- person if (ckDispatchPerson.Checked) { oPrice.Dispatch_person = 1; } else { oPrice.Dispatch_person = 0; } // --- curier if (ckDispatchCurier.Checked) { oPrice.Dispatch_curier = 1; } else { oPrice.Dispatch_curier = 0; } // --- transport if (ckDispatchTransport.Checked) { oPrice.Dispatch_transport = 1; } else { oPrice.Dispatch_transport = 0; } // --- fax if (ckDispatchFax.Checked) { oPrice.Dispatch_fax = 1; } else { oPrice.Dispatch_fax = 0; } if (!(result_price = faPrice.Update(oPrice))) { result_price = faPrice.Insert(oPrice); } // --- save contacts CPerson oContact = new CPerson(); CPersonFactory faPerson = new CPersonFactory(); CPrice_company_person oPrice_company_person = new CPrice_company_person(); CPrice_company_personFactory faPrice_company_person = new CPrice_company_personFactory(); // --- delete all if (result_price) { oPrice_version = new CPrice_version(); CPrice_versionFactory faPrice_version = new CPrice_versionFactory(); oPrice_version.Idprice = oPrice.Idprice; oPrice_version.Idcompany = null; if (cbCompany.EditValue != null) { oPrice_version.Idcompany = Convert.ToInt16(cbCompany.EditValue); } oPrice_version.Cod_type_sample = cbTypeSample.EditValue.ToString(); oPrice_version.Num_version = new ModPrice().GetNextNumVersion(oPrice.Idprice); oPrice_version.Date_creation = deDateCreation.DateTime; oPrice_version.Num_days_valid = Convert.ToInt16(tbNumDaysValid.Value); oPrice_version.Observation = tbObservation.Text; oPrice_version.Iduser = Comun.User_system.Iduser; oPrice_version.Status_price = 1; bool result_price_version = false; if (!(result_price_version = faPrice_version.Update(oPrice_version))) { result_price_version = faPrice_version.Insert(oPrice_version); } if (result_price_version) { //guardar párrafos iniciales CMemo_price oMemoPrice; CMemo_priceFactory faMemo_price = new CMemo_priceFactory(); //guardando el parrafo inicial oMemoPrice = new CMemo_price(); oMemoPrice.Idprice_version = oPrice_version.Idprice_version; oMemoPrice.Paragraph = richTextIni.RichTextBox.Rtf; oMemoPrice.Memo_type = 1; faMemo_price.Insert(oMemoPrice); //guardando el parrafo final oMemoPrice = new CMemo_price(); oMemoPrice.Idprice_version = oPrice_version.Idprice_version; oMemoPrice.Paragraph = richTextEnd.RichTextBox.Rtf; oMemoPrice.Memo_type = 2; faMemo_price.Insert(oMemoPrice); if (ckSaveHistoryIni.Checked) { CMemo_template oMemo_template = new CMemo_template(); CMemo_templateFactory faMemo_template = new CMemo_templateFactory(); oMemo_template.Paragraph = richTextIni.RichTextBox.Text; oMemo_template.Paragraph_rtf = richTextIni.RichTextBox.Rtf.ToString(); oMemo_template.Memo_type = 1; faMemo_template.Insert(oMemo_template); } //guardar párrafos finales if (ckSaveHistoryEnd.Checked) { CMemo_template oMemo_template = new CMemo_template(); CMemo_templateFactory faMemo_template = new CMemo_templateFactory(); oMemo_template.Paragraph_rtf = richTextEnd.RichTextBox.Rtf; oMemo_template.Paragraph = richTextEnd.RichTextBox.Text.ToString(); oMemo_template.Memo_type = 2; faMemo_template.Insert(oMemo_template); } } if (result_price) { CCompany_person oCompany_person = new CCompany_person(); CCompany_personFactory faCompany_person = new CCompany_personFactory(); for (int i = 0; i < gvContact.RowCount; i++) { oContact.Idperson = Convert.ToInt16(gvContact.GetRowCellValue(i, gcCon_Idperson)); oContact.Phone = gvContact.GetRowCellValue(i, gcCon_Phone).ToString(); oContact.Cellphone = gvContact.GetRowCellValue(i, gcCon_Cellphone).ToString(); oContact.Mail = gvContact.GetRowCellValue(i, gcCon_Mail).ToString(); oContact.Allname = gvContact.GetRowCellValue(i, gcCon_Allname).ToString(); bool result_contact = false; if (!(result_contact = faPerson.Update(oContact))) { result_contact = faPerson.Insert(oContact); } if (result_contact) { oPrice_company_person = new CPrice_company_person(); oPrice_company_person.Idprice_company_person = 0; oPrice_company_person.Idcompany = oCompany.Idcompany; oPrice_company_person.Idprice = oPrice.Idprice; oPrice_company_person.Idperson = oContact.Idperson; oPrice_company_person.Idprice_version = oPrice_version.Idprice_version; oPrice_company_person.Person_type = Convert.ToInt16(gvContact.GetRowCellValue(i, gcCon_Person_type)); if (!faPrice_company_person.Update(oPrice_company_person)) { faPrice_company_person.Insert(oPrice_company_person); } } // --- save history company person if (!faCompany_person.GetAll().Exists(c => c.Idcompany == oCompany.Idcompany && c.Idperson == oContact.Idperson)) { oCompany_person = new CCompany_person(); oCompany_person.Idcompany = oCompany.Idcompany; oCompany_person.Idperson = oContact.Idperson; if (!faCompany_person.Update(oCompany_person)) { faCompany_person.Insert(oCompany_person); } } } } if (result_price_version) { // guardar detalle CPrice_version_detail oPrice_version_detail = new CPrice_version_detail(); CPrice_version_detailFactory faPrice_version_detail = new CPrice_version_detailFactory(); for (int i = 0; i < gvPrice.RowCount; i++) { oPrice_version_detail = new CPrice_version_detail(); oPrice_version_detail.Idprice_version = oPrice_version.Idprice_version; oPrice_version_detail.Idtemplate_method = Convert.ToInt32(gvPrice.GetRowCellValue(i, gcolItem_Idtemplate_method)); oPrice_version_detail.Num_item = Convert.ToInt32(gvPrice.GetRowCellValue(i, gcolItem_Num_item)); oPrice_version_detail.Amount_item = Convert.ToInt32(gvPrice.GetRowCellValue(i, gcolItem_Amount_item)); oPrice_version_detail.Sale_price = Convert.ToDecimal(gvPrice.GetRowCellValue(i, gcolItem_Sale_price)); oPrice_version_detail.Unit_price = Convert.ToDecimal(gvPrice.GetRowCellValue(i, gcolItem_Unit_price)); if (!faPrice_version_detail.Update(oPrice_version_detail)) { faPrice_version_detail.Insert(oPrice_version_detail); } } } if (result_price_version) { if (gvAnexos.RowCount > 0) { // guardar adjuntos ListCopy lstCopySave = new ListCopy(); List <Anexos> lstAnexos = (gcAnexos.DataSource as BindingList <Anexos>).ToList(); if (lstAnexos != null && lstAnexos.Count > 0) { foreach (Anexos item in lstAnexos) { if (item.Source_filename.Trim().Length > 0) { string destiny_directory = oSettings.GetPathAttachPrice(); lstCopySave.Add( new CItemCopy() { Filename = item.Filename, Source_file = item.Source_filename, Destiny_directory = destiny_directory }); } } lstCopySave.Save(oPrice, oPrice_version); } } } } return(true); }
protected override void Recuperar_Registro() { CCompanyFactory faCompany = new CCompanyFactory(); CCompany oCompany = faCompany.GetByPrimaryKey(new CCompanyKeys(IDCompany)); if (oCompany != null) { tbBusinessName.Text = oCompany.Business_name; tbClientRuc.Text = oCompany.Ruc; tbClientDomicile.Text = oCompany.Domicile; tbClientEmail.Text = oCompany.Mail; tbClientPhone.Text = oCompany.Phone_client; cbTypeCompany.EditValue = Convert.ToChar(oCompany.Type_company); } }
bool SaveRegisterReception() { bool result = false; object obj = deHourReception.EditValue; try { #region save head if (oRecep_sample == null) oRecep_sample = new CRecep_sample(); else { if (loadData == LoadData.FromRR_ToExtendRR) oRecep_sample.Idrecep_sample = 0; } CPersonFactory faPerson = new CPersonFactory(); Reception oReception = new BusinessLayer.Modules.Reception(); // --- save company bool result_company = false; CCompany oCompany = new CCompany(); if (cbCompany.EditValue != null) { CCorr_modulesFactory faCorr_modules = new CCorr_modulesFactory(); CCompanyFactory faCompany = new CCompanyFactory(); oCompany.Idcompany = Convert.ToInt16(cbCompany.EditValue); //oCompany.Cod_company = faCorr_modules.GetCorrModule(Comun.Formulario.fmEmpresa.ToString()); oCompany.Ruc = tbClientRuc.Text; oCompany.Business_name = cbCompany.Text; oCompany.Domicile = tbClientDomicile.Text; oCompany.Type_company = 'C'; // --- client oCompany.Phone_client = tbClientPhone.Text; if (!(result_company = faCompany.Update(oCompany))) result_company = faCompany.Insert(oCompany); } // --- save head if (!result_company) { ComunForm.Send_message(this.Text, TypeMsg.error, "Error al guardar cliente, no se pudo completar la operación."); return false; } bool result_recep_sample = false; oReception.GetNewCodReception(); oRecep_sample.Cod_recep_sample = oReception.GetFormatCodReception(); oRecep_sample.Idcompany = oCompany.Idcompany; oRecep_sample.Date_reception = deReception.DateTime; DateTime Hour_reception = Convert.ToDateTime(deHourReception.EditValue); oRecep_sample.Date_reception = new DateTime( deReception.DateTime.Year, deReception.DateTime.Month, deReception.DateTime.Day, Hour_reception.Hour, Hour_reception.Minute, Hour_reception.Second); DateTime Hour_result = Convert.ToDateTime(deHourResult.EditValue); oRecep_sample.Date_result = new DateTime( deResult.DateTime.Year, deResult.DateTime.Month, deResult.DateTime.Day, Hour_result.Hour, Hour_result.Minute, Hour_result.Second); oRecep_sample.Cod_type_sample = cbTypeSample.EditValue.ToString(); oRecep_sample.Total_amount = Convert.ToDecimal(tbSubTotalAmount.Text); oRecep_sample.Total_igv = Convert.ToDecimal(tbTotalIgv.Text); oRecep_sample.Total_amount_igv = Convert.ToDecimal(tbTotalAmount.Text); oRecep_sample.Amortization = Convert.ToDecimal(tbAmortization.Text); oRecep_sample.Flag_isprice = false; //oRecep_sample.Discount = ckDiscount.Checked == true ? tbDiscount.Value : 0; if (oRecep_sample.Idrecep_sample == 0) { oRecep_sample.Usernew = Comun.GetUser(); oRecep_sample.Datenew = Comun.GetDate(); } oRecep_sample.Useredit = Comun.GetUser(); oRecep_sample.Dateedit = Comun.GetDate(); if (!(result_recep_sample = faRecep_sample.Update(oRecep_sample))) result_recep_sample = faRecep_sample.Insert(oRecep_sample); if (!result_recep_sample) { ComunForm.Send_message(this.Text, TypeMsg.error, "Error al guardar datos en recepción, no se pudo completar la operación."); return false; } #endregion #region update price if (result_recep_sample && oPrice_version != null && oPrice_version.Idprice_version > 0) { oPrice_version.Status_price = 4; faPrice_version.Update(oPrice_version); } #endregion #region save detail // --- contacts and detail if (result_recep_sample) { // --- save contacts CPerson oContact = new CPerson(); CRecep_company_person oRecep_company_person = new CRecep_company_person(); CRecep_company_personFactory faRecep_company_person = new CRecep_company_personFactory(); // --- delete all tbCod_recep_sample.Text = oReception.GetFormatCodReception(); oReception.SetDisabledContact(oRecep_sample.Idrecep_sample); for (int i = 0; i < gvContact.RowCount; i++) { oContact.Idperson = Convert.ToInt16(gvContact.GetRowCellValue(i, gcCon_Idperson)); oContact.Phone = gvContact.GetRowCellValue(i, gcCon_Phone).ToString(); oContact.Cellphone = gvContact.GetRowCellValue(i, gcCon_Cellphone).ToString(); oContact.Mail = gvContact.GetRowCellValue(i, gcCon_Mail).ToString(); oContact.Allname = gvContact.GetRowCellValue(i, gcCon_Allname).ToString(); bool result_contact = false; if (!(result_contact = faPerson.Update(oContact))) result_contact = faPerson.Insert(oContact); if (result_contact) { oRecep_company_person = new CRecep_company_person(); oRecep_company_person.Idrecep_company_person = 0; oRecep_company_person.Idcompany = oCompany.Idcompany; oRecep_company_person.Idrecep_sample = oRecep_sample.Idrecep_sample; oRecep_company_person.Idperson = oContact.Idperson; oRecep_company_person.Person_type = Convert.ToInt16(gvContact.GetRowCellValue(i, gcCon_Person_type)); oRecep_company_person.Enabled_show = true; if (!faRecep_company_person.Update(oRecep_company_person)) faRecep_company_person.Insert(oRecep_company_person); } } // --- save dispatch CRecep_sample_dispatchFactory faRecep_sample_dispatch = new CRecep_sample_dispatchFactory(); CRecep_sample_dispatch oRecep_sample_dispatch = new CRecep_sample_dispatch(); oRecep_sample_dispatch.Idrecep_sample = oRecep_sample.Idrecep_sample; // --- person if (ckDispatchPerson.Checked) oRecep_sample_dispatch.Dispatch_person = 1; else oRecep_sample_dispatch.Dispatch_person = 0; // --- curier if (ckDispatchCurier.Checked) oRecep_sample_dispatch.Dispatch_curier = 1; else oRecep_sample_dispatch.Dispatch_curier = 0; // --- transport if (ckDispatchTransport.Checked) oRecep_sample_dispatch.Dispatch_transport = 1; else oRecep_sample_dispatch.Dispatch_transport = 0; // --- fax if (ckDispatchFax.Checked) oRecep_sample_dispatch.Dispatch_fax = 1; else oRecep_sample_dispatch.Dispatch_fax = 0; // --- save if (!faRecep_sample_dispatch.Update(oRecep_sample_dispatch)) faRecep_sample_dispatch.Insert(oRecep_sample_dispatch); // --------------------------------------------------------------------------- // --- save detail ----------------------------------------------------------- // --------------------------------------------------------------------------- CRecep_sample_detail oRecep_sample_detail = new CRecep_sample_detail(); CRecep_sample_detailFactory faRecep_sample_detail = new CRecep_sample_detailFactory(); CRecep_elem oRecep_elem = new CRecep_elem(); CRecep_elemFactory faRecep_elem = new CRecep_elemFactory(); CRecep_sample_detail_elem oRecep_sample_detail_elem = new CRecep_sample_detail_elem(); CRecep_sample_detail_elemFactory faRecep_sample_detail_elem = new CRecep_sample_detail_elemFactory(); CCorrelative oCorrelative = new CCorrelativeFactory().GetByPrimaryKey(new CCorrelativeKeys(oRecep_sample.Cod_type_sample)); if (oRecep_sample.Idrecep_sample > 0) { int i = 0; while (i < gvReception.RowCount) { oRecep_sample_detail = new CRecep_sample_detail(); oRecep_sample_detail.Idrecep_sample = oRecep_sample.Idrecep_sample; //if (gvReception.GetRowCellValue(i, gcRec_idrecep_sample_detail) != DBNull.Value) //oRecep_sample_detail.Idrecep_sample_detail = Convert.ToInt64(gvReception.GetRowCellValue(i, gcRec_idrecep_sample_detail)); oRecep_sample_detail.Idrecep_sample_detail = 0; oRecep_sample_detail.Order_sample = Convert.ToInt16(gvReception.GetRowCellValue(i, gcRec_OrderSample)); oRecep_sample_detail.Name_sample = gvReception.GetRowCellValue(i, gcRec_NameSample).ToString(); oRecep_sample_detail.Procedence = gvReception.GetRowCellValue(i, gcRec_Procedence).ToString(); oRecep_sample_detail.Cod_des_sample = gvReception.GetRowCellValue(i, gcRec_Description).ToString(); oRecep_sample_detail.Cod_type_sample = gvReception.GetRowCellValue(i, gcRec_Type_Sample).ToString(); oRecep_sample_detail.Cod_sample = gvReception.GetRowCellValue(i, gcRec_Code).ToString(); oRecep_sample_detail.Amount_weight = Convert.ToDecimal(gvReception.GetRowCellValue(i, gcRec_CantKg)); oRecep_sample_detail.Cost_sample = Convert.ToDecimal(gvReception.GetRowCellValue(i, gcRec_Cost)); oRecep_sample_detail.Flag_envelope_sealed = Convert.ToBoolean(gvReception.GetRowCellValue(i, gcRec_Flag_envelope_sealed)); oRecep_sample_detail.Flag_reject = Convert.ToBoolean(gvReception.GetRowCellValue(i, gcRec_Reject)); oRecep_sample_detail.Flag_counter_sample = Convert.ToInt16(gvReception.GetRowCellValue(i, gcRec_Counter_Sample)); oRecep_sample_detail.Analisys_time = Convert.ToInt16(gvReception.GetRowCellValue(i, gcRec_Days)); bool result_detail_elem = false; bool result_recep_sample_detail = false; if (!(result_recep_sample_detail = faRecep_sample_detail.Update(oRecep_sample_detail))) result_recep_sample_detail = faRecep_sample_detail.Insert(oRecep_sample_detail); if (result_recep_sample_detail) { if (FlagRegRecepCopy) { oRecep_sample_detail.Cod_interno = Convert.ToInt64(gvReception.GetRowCellValue(i, gcRec_Cod_interno)); oRecep_sample_detail.Cod_sample = gvReception.GetRowCellValue(i, gcRec_Code).ToString(); oRecep_sample_detail.Flag_control_sample = false; } else { // assign correlative code long Cod_interno = oReception.GetNewCodInternoSample(gvReception.GetRowCellValue(i, gcRec_Type_Sample).ToString()); string Format_cod_interno = oReception.GetFormatCodInternoSample(gvReception.GetRowCellValue(i, gcRec_Type_Sample).ToString()); oRecep_sample_detail.Cod_interno = Cod_interno; oRecep_sample_detail.Cod_sample = Format_cod_interno; oRecep_sample_detail.Flag_control_sample = false; } faRecep_sample_detail.Update(oRecep_sample_detail); #region save element cell repetition CRecep_sample_detail oRecep_sample_aux = faRecep_sample_detail.GetByPrimaryKey(new CRecep_sample_detailKeys(oRecep_sample_detail.Idrecep_sample_detail)); CSettings oSettings = new CSettings(); bool HasHumidityAnalysis = false; bool Has60GradesElement = false; // --- retrieve code sample and assign if (!Convert.ToBoolean(oRecep_sample_detail.Flag_control_sample)) gvReception.SetRowCellValue(i, gcRec_Code, oRecep_sample_aux.Cod_sample); // --- save element cell foreach (KeyValuePair<DevExpress.XtraGrid.Columns.GridColumn, bool> kvp in DicShowColumns) { if (kvp.Value) { bool value_check = Convert.ToBoolean(gvReception.GetRowCellValue(i, kvp.Key)); bool flag_control_sample = Convert.ToBoolean(oRecep_sample_detail.Flag_control_sample); if ((!flag_control_sample && value_check) || flag_control_sample) { oRecep_sample_detail_elem = new CRecep_sample_detail_elem(); CTagInfoMethod tagMethod = (CTagInfoMethod)kvp.Key.Tag; oRecep_sample_detail_elem.Idelement = tagMethod.IDElement; oRecep_sample_detail_elem.Idrecep_sample = oRecep_sample.Idrecep_sample; oRecep_sample_detail_elem.Idrecep_sample_detail = oRecep_sample_detail.Idrecep_sample_detail; oRecep_sample_detail_elem.Idtemplate_method = tagMethod.IDTemplate_method; oRecep_sample_detail_elem.Idcompany = oRecep_sample.Idcompany; oRecep_sample_detail_elem.Idunit = tagMethod.IDMeasurement_Unit; oRecep_sample_detail_elem.Cost_method = tagMethod.Cost_Method; if (!(result_detail_elem = faRecep_sample_detail_elem.Update(oRecep_sample_detail_elem))) result_detail_elem = faRecep_sample_detail_elem.Insert(oRecep_sample_detail_elem); if (result_detail_elem) { // crear bandejas CBatchManager oBatchManager = new CBatchManager(); oBatchManager.CallSaveSampleBatch( Convert.ToInt32(oRecep_sample_detail_elem.Idtemplate_method), Convert.ToInt64(oRecep_sample_detail_elem.Idrecep_sample), Convert.ToInt64(oRecep_sample_detail_elem.Idrecep_sample_detail), oRecep_sample_detail_elem.Idrecep_sample_detail_elem, Convert.ToInt64(oRecep_sample_detail.Cod_interno), oRecep_sample_detail.Cod_sample, Comun.GetUser(), oCorrelative); // enviar a preparación de muestras } //verificar si tiene análisis por humedad if (oSettings.GetIdHumidityAnalysis().Contains(tagMethod.IDElement.ToString())) HasHumidityAnalysis = true; //verificar si tiene que elementos para ser analizados a 60° if (oSettings.GetIDElements60Grades().Contains(tagMethod.IDElement.ToString())) Has60GradesElement = true; } } } #endregion #region save sample preparation CPrep_samples oPrep_samples = new CPrep_samples(); oPrep_samples.Idrecep_sample_detail = oRecep_sample_detail.Idrecep_sample_detail; oPrep_samples.Flag_counter_sample = oRecep_sample_detail.Flag_counter_sample; oPrep_samples.Flag_reject = oRecep_sample_detail.Flag_reject; oPrep_samples.Flag_humidity_analysis = HasHumidityAnalysis; oPrep_samples.Flag_60celsius = Has60GradesElement; oPrep_samples.Date_creation = Comun.GetDate(); oPrep_samples.Moisture_reject = false; oPrep_samples.Final_moisture = 0; oPrep_samples.Final_reject = 0; oPrep_samples.Final_sample_prepared = 0; oPrep_samples.Final_weight_gross = 0; oPrep_samples.Output_flag_sample = false; oPrep_samples.Output_flag_cs = false; oPrep_samples.Output_flag_re = false; CPrep_samplesFactory faPrep_samples = new CPrep_samplesFactory(); if (!faPrep_samples.Update(oPrep_samples)) faPrep_samples.Insert(oPrep_samples); #endregion } if (!Convert.ToBoolean(oRecep_sample_detail.Flag_control_sample)) i++; } } #region save tag infor method // --- save tag info method (mr or blk) foreach (KeyValuePair<DevExpress.XtraGrid.Columns.GridColumn, bool> kvp in DicShowColumns) { if (kvp.Value) { CTagInfoMethod tagMethod = (CTagInfoMethod)kvp.Key.Tag; oRecep_elem = new CRecep_elem(); oRecep_elem.Idelement = tagMethod.IDElement; oRecep_elem.Idrecep_sample = oRecep_sample.Idrecep_sample; oRecep_elem.Idtemplate_method = tagMethod.IDTemplate_method; oRecep_elem.Name_unit = tagMethod.Name_Measurement_Unit; oRecep_elem.Idunit = tagMethod.IDMeasurement_Unit; oRecep_elem.Percent_repetition = tagMethod.Percent_repetition; if (!faRecep_elem.Update(oRecep_elem)) faRecep_elem.Insert(oRecep_elem); } } #endregion } #endregion result = true; } catch (Exception ex) { Comun.Save_log(ex.Message); if (ex.InnerException != null) Comun.Save_log(ex.InnerException.ToString()); return false; } return result; }
private void cbClientName_ChangeItem() { // --- assign idClient to private variable IDCompany = Convert.ToInt16(cbCompany.EditValue); CCompany oCompany = new CCompanyFactory().GetByPrimaryKey(new CCompanyKeys(IDCompany)); if (oCompany != null) { tbClientDomicile.Text = oCompany.Domicile; tbClientRuc.Text = oCompany.Ruc; tbClientPhone.Text = oCompany.Phone_client; } }
void RetrieveRegisterReception() { // --- return date of recep_sample DicCellsSavedReport.Clear(); DicCellsSaveProgram.Clear(); Reception oReception = new Reception(); if (oRecep_sample != null) { tpRightReports.PageVisible = true; tpRightAttach.PageVisible = true; tpRightProgram.PageVisible = true; txIdrecep_sample.Text = oRecep_sample.Idrecep_sample.ToString(); statusRegReception = StatusRegRecep.reg_recep_saved; tbCod_recep_sample.Text = oRecep_sample.Cod_recep_sample; deReception.DateTime = Convert.ToDateTime(oRecep_sample.Date_reception); deHourReception.EditValue = Convert.ToDateTime(oRecep_sample.Date_reception); deResult.DateTime = Convert.ToDateTime(oRecep_sample.Date_result); deHourResult.EditValue = Convert.ToDateTime(oRecep_sample.Date_result); cbTypeSample.EditValue = oRecep_sample.Cod_type_sample; tbNumDays.Value = Convert.ToDecimal(Convert.ToDateTime(oRecep_sample.Date_result).Subtract(Convert.ToDateTime(oRecep_sample.Date_reception)).TotalDays); tbSubTotalAmount.Text = oRecep_sample.Total_amount.ToString(); tbTotalIgv.Text = oRecep_sample.Total_igv.ToString(); tbTotalAmount.Text = oRecep_sample.Total_amount_igv.ToString(); tbAmortization.Text = oRecep_sample.Amortization.ToString(); if (oRecep_sample.Amortization.Value == 0) tbResidue.BackColor = Color.Coral; CCompany oCompany = new CCompanyFactory().GetByPrimaryKey(new CCompanyKeys(Convert.ToInt16(oRecep_sample.Idcompany))); // --- retrieve dispatch CRecep_sample_dispatch oRecep_sample_dispatch = new CRecep_sample_dispatchFactory().GetByPrimaryKey(new CRecep_sample_dispatchKeys(oRecep_sample.Idrecep_sample)); if (oRecep_sample_dispatch != null) { // --- person if (oRecep_sample_dispatch.Dispatch_person > 0) ckDispatchPerson.Checked = true; else ckDispatchPerson.Checked = false; // --- curier if (oRecep_sample_dispatch.Dispatch_curier > 0) ckDispatchCurier.Checked = true; else ckDispatchCurier.Checked = false; // --- transport if (oRecep_sample_dispatch.Dispatch_transport > 0) ckDispatchTransport.Checked = true; else ckDispatchTransport.Checked = false; // --- fax if (oRecep_sample_dispatch.Dispatch_fax > 0) ckDispatchFax.Checked = true; else ckDispatchFax.Checked = false; } else { ckDispatchPerson.Checked = false; ckDispatchCurier.Checked = true; ckDispatchTransport.Checked = false; ckDispatchFax.Checked = false; } // --- return date of client if (oCompany != null) { IDCompany = oCompany.Idcompany; cbCompany.EditValue = oCompany.Idcompany; tbClientRuc.Text = oCompany.Ruc; tbClientPhone.Text = oCompany.Phone_client; tbClientDomicile.Text = oCompany.Domicile; // --- get contacts gcContact.DataSource = new BindingList<CContact>(oReception.GetLstContactsByRecep(oRecep_sample.Idrecep_sample)); // --- return recep_sample_detail CRecep_sample_detail oRecep_sample_detail = new CRecep_sample_detail(); CRecep_sample_detailFactory faRecep_sample_detail = new CRecep_sample_detailFactory(); DTReceptionDetail = oReception.GetReceptionDetail(oRecep_sample.Idrecep_sample); gcReception.DataSource = DTReceptionDetail; // --- return columns List<CTemplate_method> lstTemplate_method = oReception.GetReceptionElem(oRecep_sample.Idrecep_sample); // --- modify the dictionary show columns if (loadData != LoadData.FromRR_ToExtendRR) { foreach (CTemplate_method oTemplate_method in lstTemplate_method) AddColumn(oTemplate_method.Cod_template_method); // --- get columns and value cells GetSampleByElems(); } // ==================< Retrieve report groups >============================================== gcReport.DataSource = oReception.GetRecep_sample_report(oRecep_sample.Idrecep_sample); CCells_reportedFactory faCells_reported = new CCells_reportedFactory(); for (int i = 0; i < gvReport.RowCount; i++) { long idrecep_sample_report = Convert.ToInt64(gvReport.GetRowCellValue(i, gcRep_idrecep_sample_report)); short order = Convert.ToInt16(gvReport.GetRowCellValue(i, gcRep_order_report)); Color color = dicColorReport[Convert.ToInt16(gvReport.GetRowCellValue(i, gcRep_report_status))]; List<CCells_reported> lstRsder = faCells_reported.GetAll().Where(x=> x.Idrecep_sample_report == idrecep_sample_report).ToList(); List<CPositionValue> lstPositionValue = new List<CPositionValue>(); foreach (CCells_reported item in lstRsder) { if (item.Idrecep_sample_report == idrecep_sample_report) { CPositionValue oPosition = new CPositionValue(); oPosition = GetObjectPosition(Convert.ToInt64(item.Idrecep_sample_detail_elem), Convert.ToInt32(item.Idtemplate_method)); oPosition.idtemplate_method = Convert.ToInt32(item.Idtemplate_method); oPosition.idrecep_sample_report = Convert.ToInt64(item.Idrecep_sample_report); oPosition.idrecep_sample_detail = Convert.ToInt64(item.Idrecep_sample_detail); oPosition.idrecep_sample_detail_elem = Convert.ToInt64(item.Idrecep_sample_detail_elem); oPosition.idcell_reported = Convert.ToInt64(item.Idcell_reported); if (Convert.ToInt16(gvReport.GetRowCellValue(i, gcRep_type_report)) == 1) oPosition.color = Partial_report_color; else oPosition.color = Final_report_color; lstPositionValue.Add(oPosition); } } DicCellsSavedReport.Add(order, lstPositionValue); } // ==================< Unreport data >====================================================== GetUnreportData(oRecep_sample.Idrecep_sample); // ==================< Retrieve attach files >============================================== gcAttachFile.DataSource = new BindingList<CDocAttach>(oReception.GetLstDocAttach(oRecep_sample.Idrecep_sample)); CCells_attach_fileFactory faCells_attach_file = new CCells_attach_fileFactory(); for (int i = 0; i < gvAttachFile.RowCount; i++) { long idrecep_sample_attach = Convert.ToInt64(gvAttachFile.GetRowCellValue(i, gcAtt_Idrecep_sample_attach)); short order = Convert.ToInt16(gvAttachFile.GetRowCellValue(i, gcAtt_Order_file)); Color color = dicColorAttach[Convert.ToInt16(gvAttachFile.GetRowCellValue(i, gcAtt_Attach_status))]; List<CCells_attach_file> lstRsder = oReception.GetLstCellsAttachFile(idrecep_sample_attach); List<CpositionValueAttach> lstPositionValue = new List<CpositionValueAttach>(); foreach (CCells_attach_file item in lstRsder) { if (item.Idrecep_sample_attach == idrecep_sample_attach) { CpositionValueAttach oPosition = new CpositionValueAttach(); oPosition = GetObjectPositionAttach(Convert.ToInt64(item.Idrecep_sample_detail_elem), Convert.ToInt32(item.Idtemplate_method)); oPosition.idrecep_sample_detail_elem = Convert.ToInt64(item.Idrecep_sample_detail_elem); oPosition.idtemplate_method = Convert.ToInt32(item.Idtemplate_method); oPosition.color = color; lstPositionValue.Add(oPosition); } } DicCellsSavedAttach.Add(order, lstPositionValue); } // ==================< Retrieve program >============================================== gcProgram.DataSource = oReception.GetRecep_sample_program(oRecep_sample.Idrecep_sample); CCells_programFactory faCells_program = new CCells_programFactory(); for (int i = 0; i < gvProgram.RowCount; i++) { long idrecep_sample_program = Convert.ToInt64(gvProgram.GetRowCellValue(i, gcProg_Idrecep_sample_program)); short order = Convert.ToInt16(gvProgram.GetRowCellValue(i, gcProg_Order_report)); Color color = Comun.ColorRojo; List<CCells_program> lstProgram = oReception.GetLstCellsProgram(idrecep_sample_program); List<CPositionValueProgram> lstPositionValueProgram = new List<CPositionValueProgram>(); foreach (CCells_program item in lstProgram) { if (item.Idrecep_sample_program == idrecep_sample_program) { CPositionValueProgram oPosition = new CPositionValueProgram(); oPosition = GetObjectPositionProgram(Convert.ToInt64(item.Idrecep_sample_detail_elem), Convert.ToInt32(item.Idtemplate_method)); oPosition.idrecep_sample_program = Convert.ToInt64(item.Idrecep_sample_program); oPosition.idrecep_sample_detail_elem = Convert.ToInt64(item.Idrecep_sample_detail_elem); oPosition.idrecep_sample_detail = Convert.ToInt64(item.Idrecep_sample_detail); oPosition.idtemplate_method = Convert.ToInt32(item.Idtemplate_method); oPosition.color = color; lstPositionValueProgram.Add(oPosition); } } DicCellsSaveProgram.Add(order, lstPositionValueProgram); } } SortColumnsByCodTemplate(); } else { ///No existe un registro de recepción, entonces recuperar todo vacio // --- hide tappages tpRightReports.PageVisible = false; tpRightAttach.PageVisible = false; tpRightProgram.PageVisible = false; // --- return empty report CRecep_sample_reportFactory faRecep_sample_report = new CRecep_sample_reportFactory(); gcReport.DataSource = oReception.GetRecep_sample_report(0); // --- return empty attach files gcAttachFile.DataSource = new BindingList<CDocAttach>(oReception.GetLstDocAttach(0)); // --- recuperar contactos if (cbCompany.EditValue != null) gcContact.DataSource = new BindingList<CContact>(oReception.GetLstContactsByCompany(Convert.ToInt16(cbCompany.EditValue))); } }
void RetrieveDataCompany() { // --- recuperate the clients if (cbCompany.EditValue != null) { if (cbCompany.EditValue.ToString().Trim() != "" && cbCompany.EditValue.ToString().Trim() != "0") { CCompany oCompany = new CCompany(); CCompanyFactory faCompany = new CCompanyFactory(); oCompany = faCompany.GetByPrimaryKey(new CCompanyKeys(Convert.ToInt16(cbCompany.EditValue))); tbClientDomicile.Text = oCompany.Domicile; tbClientPhone.Text = oCompany.Phone_client; tbClientRuc.Text = oCompany.Ruc; // --- get/show contacts Reception oReception = new BusinessLayer.Modules.Reception(); gcContact.DataSource = new BindingList<CContact>(oReception.GetLstContactsByCompany(oCompany.Idcompany)); } // --- get/show attached files Show_exist_files(); } }
void Refresh_combo_company() { // --- init client combo CCompanyFactory faCompany = new CCompanyFactory(); cbCompany.Properties.DataSource = faCompany.GetAll(); cbCompany.Properties.ValueMember = "Idcompany"; cbCompany.Properties.DisplayMember = "Business_name"; }
void InitDataControls() { deReception.DateTime = DateTime.Now; deHourReception.EditValue = DateTime.Now; // --- init client combo CCompanyFactory faCompany = new CCompanyFactory(); cbCompany.Properties.DataSource = faCompany.GetAll(); cbCompany.Properties.ValueMember = "Idcompany"; cbCompany.Properties.DisplayMember = "Business_name"; // --- init element combo CElementFactory faElement = new CElementFactory(); lstElement = faElement.GetAll(); lstElement.Insert(0, new CElement { Idelement = -1, Cod_element = "Seleccionar" }); var elementQuery = from table in lstElement select new CItemGenericCombo { codigo = table.Idelement.ToString(), descripcion = table.Cod_element }; // --- init type sample combo CType_sampleFactory faType_Sample = new CType_sampleFactory(); cbTypeSample.Properties.DataSource = faType_Sample.GetAll(); cbTypeSample.Properties.ValueMember = "Cod_type_sample"; cbTypeSample.Properties.DisplayMember = "Name_type_sample"; // --- init description combo CDescription_sampleFactory faDescrition_Sample = new CDescription_sampleFactory(); repDescription.DataSource = faDescrition_Sample.GetAll(); repDescription.ValueMember = "Cod_des_sample"; repDescription.DisplayMember = "Description"; // --- init anio CSerieFactory faSerie = new CSerieFactory(); Reception oReception = new Reception(); // --- init status report repStatusReport.DataSource = Comun.ListStatusReport; repStatusReport.ValueMember = "IdStatus"; repStatusReport.DisplayMember = "Den_Status"; // --- init status attach repAttach_status.DataSource = oReception.GetAttachStatus(); repAttach_status.DisplayMember = "Name_status"; repAttach_status.ValueMember = "Id"; repPerson_type.DataSource = oReception.GetLstPersonType(); repPerson_type.DisplayMember = "Name"; repPerson_type.ValueMember = "Id"; }
private void FormMaterialReference_Load(object sender, EventArgs e) { // --- Initialize material of reference CMrFactory faMr = new CMrFactory(); cbCodMR.Properties.DataSource = faMr.GetAll(); cbCodMR.Properties.ValueMember = "Idmr"; cbCodMR.Properties.DisplayMember = "Cod_mr"; // --- Initialize description sample cbDescription.Properties.DataSource = Comun.ListTypeMaterial; cbDescription.Properties.ValueMember = "IdTypeMaterial"; cbDescription.Properties.DisplayMember = "Description"; // --- Initialize type of analysis CDigestion_methodFactory faDigestion_method = new CDigestion_methodFactory(); repTypeDigestion.DataSource = faDigestion_method.GetAll(); repTypeDigestion.ValueMember = "Cod_digestion_method"; repTypeDigestion.DisplayMember = "Name_digestion_method"; // --- Initialize the type of material reference cbTypeMr.Properties.DataSource = Comun.ListMr; cbTypeMr.Properties.DisplayMember = "Den_TypeMr"; cbTypeMr.Properties.ValueMember = "IdTypeMr"; // --- Initialize in container grid element CElementFactory faElement = new CElementFactory(); repElement.DataSource = faElement.GetAll(); repElement.DisplayMember = "Cod_element"; repElement.ValueMember = "Idelement"; // --- Initialize in container grid unit measurement CMeasurement_unitFactory faMeasurement_unit = new CMeasurement_unitFactory(); repTypeUnit.DataSource = faMeasurement_unit.GetAll(); repTypeUnit.DisplayMember = "Name_unit"; repTypeUnit.ValueMember = "Idunit"; // --- Inititalize list statusMr lstStatusMr = new BindingList <CStatusMr>(); lstStatusMr.Add(new CStatusMr { IDStatusMr = true, Description = "Vigente" }); lstStatusMr.Add(new CStatusMr { IDStatusMr = false, Description = "No vigente" }); cbStatus.Properties.DataSource = lstStatusMr; cbStatus.Properties.DisplayMember = "Description"; cbStatus.Properties.ValueMember = "IDStatusMr"; // --- Initialize in container grid company CCompanyFactory faCompany = new CCompanyFactory(); List <CCompany> lstCompany = faCompany.GetAll().Where(c => c.Type_company == 'P').ToList(); cbManufacturer.Properties.DataSource = lstCompany; cbManufacturer.Properties.DisplayMember = "Business_name"; cbManufacturer.Properties.ValueMember = "Idcompany"; cbCertifier.Properties.DataSource = lstCompany; cbCertifier.Properties.DisplayMember = "Business_name"; cbCertifier.Properties.ValueMember = "Idcompany"; // --- Initialize the grid GetDetailMaterialReference(); }