Exemplo n.º 1
0
        private void btnSaveGrid_Click(object sender, EventArgs e)
        {
            if (PriceListGridView.RowCount > 0)
            {
                List<VisitaJayaPerkasa.Entities.PriceList> tempPriceList = new List<VisitaJayaPerkasa.Entities.PriceList>();

                if (cboTypeSupplier.Text.ToLower().Equals("shipping lines"))
                {
                    for (int i = 0; i < PriceListGridView.RowCount; i++)
                    {
                        VisitaJayaPerkasa.Entities.PriceList objPriceList = new VisitaJayaPerkasa.Entities.PriceList();

                        string id = (PriceListGridView.Rows[i].Cells[0].Value.ToString().Equals("")) ? Guid.Empty.ToString() : PriceListGridView.Rows[i].Cells[0].Value.ToString();
                        objPriceList.ID = Utility.Utility.ConvertToUUID(id);

                        id = (PriceListGridView.Rows[i].Cells[1].Value.ToString().Equals("")) ? Utility.Utility.DefaultDateTime().ToString() : PriceListGridView.Rows[i].Cells[1].Value.ToString();
                        objPriceList.DateFrom = Utility.Utility.ConvertStringToDate(id);
                        if (objPriceList.DateFrom.ToString().Equals(Utility.Utility.DefaultDateTime().ToString()))
                        {
                            MessageBox.Show(this, "Please fill date from in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[2].Value.ToString().Equals("")) ? Utility.Utility.DefaultDateTime().ToString() : PriceListGridView.Rows[i].Cells[2].Value.ToString();
                        objPriceList.DateTo = Utility.Utility.ConvertStringToDate(id);
                        if (objPriceList.DateTo.ToString().Equals(Utility.Utility.DefaultDateTime().ToString()))
                        {
                            MessageBox.Show(this, "Please fill date to in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[5].Value.ToString().Equals("")) ? Guid.Empty.ToString() : PriceListGridView.Rows[i].Cells[5].Value.ToString();
                        objPriceList.TypeID = Utility.Utility.ConvertToUUID(id);
                        if (objPriceList.TypeID.ToString().Equals(Guid.Empty.ToString()))
                        {
                            MessageBox.Show(this, "Please fill type in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[6].Value.ToString().Equals("")) ? Guid.Empty.ToString() : PriceListGridView.Rows[i].Cells[6].Value.ToString();
                        objPriceList.ConditionID = Utility.Utility.ConvertToUUID(id);
                        if (objPriceList.ConditionID.ToString().Equals(Guid.Empty))
                        {
                            MessageBox.Show(this, "Please fill condition in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[9].Value.ToString().Equals("")) ? "-1" : PriceListGridView.Rows[i].Cells[9].Value.ToString();
                        objPriceList.PriceSupplier = Utility.Utility.ConvertStringToDecimal(id);
                        if (objPriceList.PriceSupplier.ToString().Equals("-1"))
                        {
                            MessageBox.Show(this, "Please fill price supplier in line and check your price in line " + i, "Information");
                            return;
                        }


                        if (objPriceList.DateFrom.Date > objPriceList.DateTo.Date) {
                            MessageBox.Show(this, "Please correct datefrom and dateto in line " + i, "Information");
                            return;
                        }

                        tempPriceList.Add(objPriceList);
                        objPriceList = null;
                    }



                    for (int i = 0; i < tempPriceList.Count; i++) {
                        for (int j = i+1; j < tempPriceList.Count; j++) {
                            if (
                                (
                                    tempPriceList.ElementAt(i).TypeID.ToString().Equals(tempPriceList.ElementAt(j).TypeID.ToString()) &&
                                    tempPriceList.ElementAt(i).ConditionID.ToString().Equals(tempPriceList.ElementAt(j).ConditionID.ToString())
                                )
                                &&
                                (
                                    (
                                        tempPriceList.ElementAt(i).DateFrom <= tempPriceList.ElementAt(j).DateFrom &&
                                        tempPriceList.ElementAt(i).DateTo >= tempPriceList.ElementAt(j).DateFrom
                                    )
                                    ||
                                    (
                                        tempPriceList.ElementAt(i).DateFrom >= tempPriceList.ElementAt(j).DateFrom &&
                                        tempPriceList.ElementAt(i).DateFrom <= tempPriceList.ElementAt(j).DateTo
                                    )
                                )
                              ) {
                                  MessageBox.Show(this, "Please fix record - " + i + " and record -" + j + " have same record of date, type and condition. Please remove one", "Information");
                                  return;
                            }
                        }
                    }


                    sqlPriceListRepository = new SqlPriceListRepository();
                    listPriceDeleteExistsData.Clear();
                    listIndexPriceDeleteExistsData.Clear();
                    List<int> indexDeleted = new List<int>();

                    for (int i = 0; i < tempPriceList.Count; i++) {
                        Guid exists = Guid.Empty;

                        exists = sqlPriceListRepository.GetPriceCustomerByShippingLines(tempPriceList.ElementAt(i).DateFrom, 
                                                    tempPriceList.ElementAt(i).DateTo,
                                                    tempPriceList.ElementAt(i).TypeID.ToString(),
                                                    tempPriceList.ElementAt(i).ConditionID.ToString(), 
                                                    cbSupplier.SelectedValue.ToString(),
                                                    cbDestination.SelectedValue.ToString(),
                                                    searchResultCustomer.ID.ToString());

                        if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                            MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        else if (! exists.ToString().Equals(Guid.Empty.ToString())) { 
                            DialogResult dResult = MessageBox.Show(this, "Record - " + i + " has already exist. \n If you don't want to override this data, so your data not will be save. \n Do you want to override ?", "Confirmation", MessageBoxButtons.YesNo);
                            if (dResult == DialogResult.Yes){
                                listPriceDeleteExistsData.Add(exists);
                                listIndexPriceDeleteExistsData.Add(i);
                            }
                            else
                                indexDeleted.Add(i);
                        }
                    }


                    for (int i = indexDeleted.Count - 1; i >= 0; i--)
                        tempPriceList.RemoveAt(indexDeleted.ElementAt(i));

                    for (int i = 0; i < listPriceDeleteExistsData.Count; i++) {
                        for (int j = i+1; j < listPriceDeleteExistsData.Count; j++) {
                            if (listPriceDeleteExistsData.ElementAt(i) == listPriceDeleteExistsData.ElementAt(j)) {
                                MessageBox.Show(this, "Please fix record -" + listIndexPriceDeleteExistsData.ElementAt(i) + " and record -" + listIndexPriceDeleteExistsData.ElementAt(j) + " have same record of date, type and condition. Please remove one", "Information");
                                return;   
                            }
                        }
                    }

                    sqlPriceListRepository = null;
                }
                else if (cboTypeSupplier.Text.ToLower().Equals("dooring agent")) {
                    for (int i = 0; i < PriceListGridView.RowCount; i++)
                    {
                        VisitaJayaPerkasa.Entities.PriceList objPriceList = new VisitaJayaPerkasa.Entities.PriceList();

                        string id = (PriceListGridView.Rows[i].Cells[0].Value.ToString().Equals("")) ? Guid.Empty.ToString() : PriceListGridView.Rows[i].Cells[0].Value.ToString();
                        objPriceList.ID = Utility.Utility.ConvertToUUID(id);

                        id = (PriceListGridView.Rows[i].Cells[1].Value.ToString().Equals("")) ? Utility.Utility.DefaultDateTime().ToString() : PriceListGridView.Rows[i].Cells[1].Value.ToString();
                        objPriceList.DateFrom = Utility.Utility.ConvertStringToDate(id);
                        if (objPriceList.DateFrom.ToString().Equals(Utility.Utility.DefaultDateTime().ToString()))
                        {
                            MessageBox.Show(this, "Please fill date from in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[2].Value.ToString().Equals("")) ? Utility.Utility.DefaultDateTime().ToString() : PriceListGridView.Rows[i].Cells[2].Value.ToString();
                        objPriceList.DateTo = Utility.Utility.ConvertStringToDate(id);
                        if (objPriceList.DateTo.ToString().Equals(Utility.Utility.DefaultDateTime().ToString()))
                        {
                            MessageBox.Show(this, "Please fill date to in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[5].Value.ToString().Equals("")) ? Guid.Empty.ToString() : PriceListGridView.Rows[i].Cells[5].Value.ToString();
                        objPriceList.TypeID = Utility.Utility.ConvertToUUID(id);
                        if (objPriceList.TypeID.ToString().Equals(Guid.Empty.ToString()))
                        {
                            MessageBox.Show(this, "Please fill type in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[9].Value.ToString().Equals("")) ? "-1" : PriceListGridView.Rows[i].Cells[9].Value.ToString();
                        objPriceList.PriceSupplier = Utility.Utility.ConvertStringToDecimal(id);
                        if (objPriceList.PriceSupplier.ToString().Equals("-1"))
                        {
                            MessageBox.Show(this, "Please fill price supplier in line and check your price in line " + i, "Information");
                            return;
                        }

                        if (objPriceList.DateFrom.Date > objPriceList.DateTo.Date)
                        {
                            MessageBox.Show(this, "Please correct datefrom and dateto in line " + i, "Information");
                            return;
                        }

                        tempPriceList.Add(objPriceList);
                        objPriceList = null;
                    }


                    for (int i = 0; i < tempPriceList.Count; i++)
                    {
                        for (int j = i + 1; j < tempPriceList.Count; j++)
                        {
                            if (
                                (
                                    tempPriceList.ElementAt(i).TypeID.ToString().Equals(tempPriceList.ElementAt(j).TypeID.ToString())
                                )
                                &&
                                (
                                    (
                                        tempPriceList.ElementAt(i).DateFrom <= tempPriceList.ElementAt(j).DateFrom &&
                                        tempPriceList.ElementAt(i).DateTo >= tempPriceList.ElementAt(j).DateFrom
                                    )
                                    ||
                                    (
                                        tempPriceList.ElementAt(i).DateFrom >= tempPriceList.ElementAt(j).DateFrom &&
                                        tempPriceList.ElementAt(i).DateFrom <= tempPriceList.ElementAt(j).DateTo
                                    )
                                )
                              )
                            {
                                MessageBox.Show(this, "Please fix record - " + i + " and record -" + j + " have same record of date and type. Please remove one", "Information");
                                return;
                            }
                        }
                    }


                    sqlPriceListRepository = new SqlPriceListRepository();
                    listPriceDeleteExistsData.Clear();
                    listIndexPriceDeleteExistsData.Clear();
                    List<int> indexDeleted = new List<int>();

                    for (int i = 0; i < tempPriceList.Count; i++)
                    {
                        Guid exists = Guid.Empty;
                        exists = sqlPriceListRepository.GetPriceCustomerByDooringAgent(
                                                    tempPriceList.ElementAt(i).DateFrom,
                                                    tempPriceList.ElementAt(i).DateTo,
                                                    tempPriceList.ElementAt(i).TypeID.ToString(),
                                                    cbSupplier.SelectedValue.ToString(),
                                                    cbDestination.SelectedValue.ToString(),
                                                    cboRecipient.SelectedValue.ToString());

                        if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                            MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        else if (!exists.ToString().Equals(Guid.Empty.ToString()))
                        {
                            DialogResult dResult = MessageBox.Show(this, "Record - " + i + " has already exist. \n If you don't want to override this data, so your data not will be save. \n Do you want to override ?", "Confirmation", MessageBoxButtons.YesNo);
                            if (dResult == DialogResult.Yes){
                                listPriceDeleteExistsData.Add(exists);
                                listIndexPriceDeleteExistsData.Add(i);
                            }
                            else
                                indexDeleted.Add(i);
                        }
                    }

                    for (int i = indexDeleted.Count - 1; i >= 0; i--)
                        tempPriceList.RemoveAt(indexDeleted.ElementAt(i));

                    for (int i = 0; i < listPriceDeleteExistsData.Count; i++)
                    {
                        for (int j = i + 1; j < listPriceDeleteExistsData.Count; j++)
                        {
                            if (listPriceDeleteExistsData.ElementAt(i) == listPriceDeleteExistsData.ElementAt(j))
                            {
                                MessageBox.Show(this, "Please fix record -" + listIndexPriceDeleteExistsData.ElementAt(i) + " and record -" + listIndexPriceDeleteExistsData.ElementAt(j) + " have same record of date and type. Please remove one", "Information");
                                return;
                            }
                        }
                    }

                    sqlPriceListRepository = null;
                }
                else if (cboTypeSupplier.Text.ToLower().Equals("trucking"))
                {
                    for (int i = 0; i < PriceListGridView.RowCount; i++)
                    {
                        VisitaJayaPerkasa.Entities.PriceList objPriceList = new VisitaJayaPerkasa.Entities.PriceList();

                        string id = (PriceListGridView.Rows[i].Cells[0].Value.ToString().Equals("")) ? Guid.Empty.ToString() : PriceListGridView.Rows[i].Cells[0].Value.ToString();
                        objPriceList.ID = Utility.Utility.ConvertToUUID(id);

                        id = (PriceListGridView.Rows[i].Cells[1].Value.ToString().Equals("")) ? Utility.Utility.DefaultDateTime().ToString() : PriceListGridView.Rows[i].Cells[1].Value.ToString();
                        objPriceList.DateFrom = Utility.Utility.ConvertStringToDate(id);
                        if (objPriceList.DateFrom.ToString().Equals(Utility.Utility.DefaultDateTime().ToString()))
                        {
                            MessageBox.Show(this, "Please fill date from in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[2].Value.ToString().Equals("")) ? Utility.Utility.DefaultDateTime().ToString() : PriceListGridView.Rows[i].Cells[2].Value.ToString();
                        objPriceList.DateTo = Utility.Utility.ConvertStringToDate(id);
                        if (objPriceList.DateTo.ToString().Equals(Utility.Utility.DefaultDateTime().ToString()))
                        {
                            MessageBox.Show(this, "Please fill date to in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[5].Value.ToString().Equals("")) ? Guid.Empty.ToString() : PriceListGridView.Rows[i].Cells[5].Value.ToString();
                        objPriceList.TypeID = Utility.Utility.ConvertToUUID(id);
                        if (objPriceList.TypeID.ToString().Equals(Guid.Empty.ToString()))
                        {
                            MessageBox.Show(this, "Please fill type in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[9].Value.ToString().Equals("")) ? "-1" : PriceListGridView.Rows[i].Cells[9].Value.ToString();
                        objPriceList.PriceSupplier = Utility.Utility.ConvertStringToDecimal(id);
                        if (objPriceList.PriceSupplier.ToString().Equals("-1"))
                        {
                            MessageBox.Show(this, "Please fill price supplier in line and check your price in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[12].Value.ToString().Equals("")) ? "-1" : PriceListGridView.Rows[i].Cells[12].Value.ToString();
                        objPriceList.PriceCourier = Utility.Utility.ConvertStringToDecimal(id);
                        if (objPriceList.PriceCourier.ToString().Equals("-1"))
                        {
                            MessageBox.Show(this, "Please fill price courier in line and check your price in line " + i, "Information");
                            return;
                        }

                        if (objPriceList.DateFrom.Date > objPriceList.DateTo.Date)
                        {
                            MessageBox.Show(this, "Please correct datefrom and dateto in line " + i, "Information");
                            return;
                        }

                        tempPriceList.Add(objPriceList);
                        objPriceList = null;
                    }


                    for (int i = 0; i < tempPriceList.Count; i++)
                    {
                        for (int j = i + 1; j < tempPriceList.Count; j++)
                        {
                            if (
                                (
                                    tempPriceList.ElementAt(i).TypeID.ToString().Equals(tempPriceList.ElementAt(j).TypeID.ToString())
                                )
                                &&
                                (
                                    (
                                        tempPriceList.ElementAt(i).DateFrom <= tempPriceList.ElementAt(j).DateFrom &&
                                        tempPriceList.ElementAt(i).DateTo >= tempPriceList.ElementAt(j).DateFrom
                                    )
                                    ||
                                    (
                                        tempPriceList.ElementAt(i).DateFrom >= tempPriceList.ElementAt(j).DateFrom &&
                                        tempPriceList.ElementAt(i).DateFrom <= tempPriceList.ElementAt(j).DateTo
                                    )
                                )
                              )
                            {
                                MessageBox.Show(this, "Please fix record - " + i + " and record -" + j + " have same record of date and type. Please remove one", "Information");
                                return;
                            }
                        }
                    }


                    sqlPriceListRepository = new SqlPriceListRepository();
                    listPriceDeleteExistsData.Clear();
                    listIndexPriceDeleteExistsData.Clear();
                    List<int> indexDeleted = new List<int>();

                    for (int i = 0; i < tempPriceList.Count; i++)
                    {
                        Guid exists = Guid.Empty;
                        exists = sqlPriceListRepository.GetPriceCustomerByTrucking(tempPriceList.ElementAt(i).DateFrom,
                                                    tempPriceList.ElementAt(i).DateTo,
                                                    tempPriceList.ElementAt(i).TypeID.ToString(),
                                                    cbSupplier.SelectedValue.ToString(),
                                                    searchResultCustomer.ID.ToString(),
                                                    cboStuffingPlace.SelectedValue.ToString());

                        if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                            MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        else if (!exists.ToString().Equals(Guid.Empty.ToString()))
                        {
                            DialogResult dResult = MessageBox.Show(this, "Record - " + i + " has already exist. \n If you don't want to override this data, so your data not will be save. \n Do you want to override ?", "Confirmation", MessageBoxButtons.YesNo);
                            if (dResult == DialogResult.Yes){
                                listPriceDeleteExistsData.Add(exists);
                                listIndexPriceDeleteExistsData.Add(i);
                            }
                            else
                                indexDeleted.Add(i);
                        }
                    }


                    for (int i = indexDeleted.Count - 1; i >= 0; i--)
                        tempPriceList.RemoveAt(indexDeleted.ElementAt(i));

                    for (int i = 0; i < listPriceDeleteExistsData.Count; i++)
                    {
                        for (int j = i + 1; j < listPriceDeleteExistsData.Count; j++)
                        {
                            if (listPriceDeleteExistsData.ElementAt(i) == listPriceDeleteExistsData.ElementAt(j))
                            {
                                MessageBox.Show(this, "Please fix record -" + listIndexPriceDeleteExistsData.ElementAt(i) + " and record -" + listIndexPriceDeleteExistsData.ElementAt(j) + " have same record of date and type. Please remove one", "Information");
                                return;
                            }
                        }
                    }

                    sqlPriceListRepository = null;
                }

                    /*
                else if (cboTypeSupplier.Text.ToLower().Equals("general"))
                {
                    for (int i = 0; i < PriceListGridView.RowCount; i++)
                    {
                        VisitaJayaPerkasa.Entities.PriceList objPriceList = new VisitaJayaPerkasa.Entities.PriceList();

                        string id = (PriceListGridView.Rows[i].Cells[0].Value.ToString().Equals("")) ? Guid.Empty.ToString() : PriceListGridView.Rows[i].Cells[0].Value.ToString();
                        objPriceList.ID = Utility.Utility.ConvertToUUID(id);

                        id = (PriceListGridView.Rows[i].Cells[1].Value.ToString().Equals("")) ? Utility.Utility.DefaultDateTime().ToString() : Utility.Utility.ChangeDateMMDD(PriceListGridView.Rows[i].Cells[1].Value.ToString());
                        objPriceList.DateFrom = Utility.Utility.ConvertStringToDate(id);
                        if (objPriceList.DateFrom.ToString().Equals(Utility.Utility.DefaultDateTime().ToString()))
                        {
                            MessageBox.Show(this, "Please fill date from in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[2].Value.ToString().Equals("")) ? Utility.Utility.DefaultDateTime().ToString() : Utility.Utility.ChangeDateMMDD(PriceListGridView.Rows[i].Cells[2].Value.ToString());
                        objPriceList.DateFrom = Utility.Utility.ConvertStringToDate(id);
                        if (objPriceList.DateFrom.ToString().Equals(Utility.Utility.DefaultDateTime().ToString()))
                        {
                            MessageBox.Show(this, "Please fill date to in line " + i, "Information");
                            return;
                        }

                        id = (PriceListGridView.Rows[i].Cells[8].Value.ToString().Equals("")) ? "-1" : PriceListGridView.Rows[i].Cells[8].Value.ToString();
                        objPriceList.PriceSupplier = Utility.Utility.ConvertStringToDecimal(id);
                        if (objPriceList.PriceSupplier.ToString().Equals("-1"))
                        {
                            MessageBox.Show(this, "Please fill price supplier in line and check your price in line " + i, "Information");
                            return;
                        }

                        if (objPriceList.DateFrom.Date > objPriceList.DateTo.Date)
                        {
                            MessageBox.Show(this, "Please correct datefrom and dateto in line " + i, "Information");
                            return;
                        }

                        tempPriceList.Add(objPriceList);
                        objPriceList = null;
                    }


                    for (int i = 0; i < tempPriceList.Count; i++)
                    {
                        for (int j = i + 1; j < tempPriceList.Count; j++)
                        {
                            if (PriceListGridView.Rows[i].Cells[1].Value.ToString().Equals(PriceListGridView.Rows[j].Cells[1].Value.ToString())
                                && PriceListGridView.Rows[i].Cells[2].Value.ToString().Equals(PriceListGridView.Rows[j].Cells[2].Value.ToString()))
                            {
                                MessageBox.Show(this, "Record -" + i + " and record -" + j + " have same record of date. Please remove one", "Information");
                                return;
                            }

                        }
                    }
                }
                */


                SqlParameter[] sqlParamDeletedPrice = null;
                SqlParameter[] sqlParamInsert = null;
                if (listPriceDeleteExistsData.Count > 0)
                {
                    string[] key = new string[listPriceDeleteExistsData.Count];
                    object[] value = new object[listPriceDeleteExistsData.Count];

                    for (int j = 0; j < listPriceDeleteExistsData.Count; j++)
                    {
                        key[j] = "priceID";
                        value[j] = listPriceDeleteExistsData.ElementAt(j);
                    }

                    sqlParamDeletedPrice = SqlUtility.SetSqlParameter(key, value);
                }

                if (tempPriceList.Count > 0)
                {
                    //14 is field who any in below for
                    string[] key = new string[tempPriceList.Count * 14];
                    object[] value = new object[tempPriceList.Count * 14];

                    int nn = 0;
                    for (int j = 0; j < tempPriceList.Count; j++)
                    {
                        key[nn] = "price_id";
                        value[nn++] = Guid.NewGuid();

                        key[nn] = "dateFrom";
                        value[nn++] = tempPriceList.ElementAt(j).DateFrom;

                        key[nn] = "dateTo";
                        value[nn++] = tempPriceList.ElementAt(j).DateTo;

                        key[nn] = "supplier_id";
                        if (cbSupplier.SelectedIndex >= 0)
                            value[nn++] = listSupplier[cbSupplier.SelectedIndex].Id;
                        else value[nn++] = Guid.Empty;

                        key[nn] = "destination";
                        if (cbDestination.SelectedIndex >= 0)
                            value[nn++] = listCity[cbDestination.SelectedIndex].ID;
                        else value[nn++] = Guid.Empty;

                        key[nn] = "type_cont_id";
                        value[nn++] = tempPriceList.ElementAt(j).TypeID;

                        key[nn] = "condition_id";
                        value[nn++] = tempPriceList.ElementAt(j).ConditionID;

                        key[nn] = "price_supplier";
                        value[nn++] = tempPriceList.ElementAt(j).PriceSupplier;

                        key[nn] = "customer_id";
                        if (searchResultCustomer != null)
                            value[nn++] = searchResultCustomer.ID;
                        else value[nn++] = Guid.Empty;

                        key[nn] = "price_customer";
                        value[nn++] = tempPriceList.ElementAt(j).PriceCustomer;

                        key[nn] = "stuffing_id";
                        if (cboStuffingPlace.SelectedIndex >= 0)
                            value[nn++] = listWarehouse[cboStuffingPlace.SelectedIndex].Id;
                        else value[nn++] = Guid.Empty;

                        key[nn] = "recipient_id";
                        if (cboRecipient.SelectedIndex >= 0)
                            value[nn++] = listRecipient[cboRecipient.SelectedIndex].ID;
                        else value[nn++] = Guid.Empty;

                        key[nn] = "price_courier";
                        value[nn++] = tempPriceList.ElementAt(j).PriceCourier;

                        key[nn] = "item";
                        value[nn++] = DBNull.Value;
                    }

                    sqlParamInsert = SqlUtility.SetSqlParameter(key, value);
                    if (sqlPriceListRepository == null)
                        sqlPriceListRepository = new SqlPriceListRepository();
                    if (sqlPriceListRepository.SavePriceList(
                        (sqlParamDeletedPrice == null) ? null : sqlParamDeletedPrice,
                        sqlParamInsert))
                    {
                        MessageBox.Show(this, "Success saving !", "Information");
                        listPriceDeleteExistsData.Clear();
                        listIndexPriceDeleteExistsData.Clear();
                    }
                    else if (!Constant.VisitaJayaPerkasaApplication.anyConnection)
                    {
                        MessageBox.Show(this, "Please check your connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }
                    else
                    {
                        MessageBox.Show(this, "Failed save data !", "Information");
                        return;
                    }
                }

                PriceListGridView.Rows.Clear();
                PriceListGridView.Enabled = false;
            }
        }